Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find button

Status
Not open for further replies.

CoffeeQuick

Programmer
Jul 6, 2004
23
0
0
GB
Hi,

I am very new to using Access, i am trying to create my first database using it.

The database is ok, but i am having problems creating a "find button" for the data access page. It should search the first field which is a numerical code.

I have looked at the help files and found vbscript code to add for the onClick event for the find button, but it does not seem to work, and I'm not sure I have setup the button in the right manor (i can't find how i point it to the right field to search).

I get the following error.

Error: 3001 Aguments are of the wrong type, are out of acceptable range, or are in conflict with one another

Here is the vbScript
Code:
<SCRIPT language=vbscript event=onclick for=Command1>
<!--
Dim rs
Set rs = MSODSC.DataPages(0).Recordset.Clone
On error resume next

rs.find "Picture Code=" & cLng(inputbox("Enter a picture code","Find"))
If (err.number <> 0) then
	Msgbox "Error: " & err.number & " " & err.Description,,"Invalid Search"
	Exit Sub
End If
If (rs.box) or (rs.eof) Then
	Msgbox "No picture found",,"Search Done"
	Exit Sub
End If
MSODSC.DataPages(0).Recordset.Bookmark = rs.Bookmark


-->
</SCRIPT>
Not knowing vbScript doesn't help either!!

Can any one help?

Thanks.

John
 
You may try to replace this:
rs.find "Picture Code="
By this:
rs.find "[Picture Code]="
And this:
rs.box
By this:
rs.bof

BTW you don't know which line of code raise the error ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Hi PH,

Thanks for your reply.
I changed to rs.box to rs.bof (this was a typo on my part), and added the [] around Picture Code, and all works fine now.

The script was copied from Microsofts help files, which you would think would have it correct (with the [] around the field name), but then again it is Microsoft so I shouldn't be surprised.

Thanks for your help.

John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top