HELP! Coding problem with Search Button

P

Phil

I have built a database and am trying to add a search facility to one of the
forms. I have a form called 'Safe-Point Units & Customers' which contains
several fields. One of these fields is named 'Serial Number (SP100-)'. I wish
to add a search button to my form so i can search for a specific serial
number. This number is 6 digits long (i.e.030014).

So far i have built my button and am now trying to add the relevant code to
make it do what i want upon 'OnClick'. I have tried copying code etc from the
Access Help pages but i just can't seem to get it to work. This is my code so
far:

<SCRIPT language=vbscript event=onclick for=command0>
<!--
' Clone the recordset.
Dim rs
Set rs = MSODSC.DataPages(0).Recordset.Clone
On error resume next
-->
rs.find "Safe-Point Serial Numer (SP100-) '%" & CStr(inputbox("Enter a
Serial Number","Find"))
&"%'"
' Custom error handling.
If (err.number <> 0) Then
Msgbox "Error: " & err.number & " " & err.description,,"Invalid Search"
Exit Sub
End If
' Check search results for success.
If (rs.bof) or (rs.eof) Then
Msgbox "Serial Number Not Found",,"Search Done"
Exit Sub
End If
MSODSC.DataPages(0).Recordset.Bookmark = rs.Bookmark
-->
</SCRIPT>

When i keep trying the button it gives me a runtime error and starts
highlighting parts of the code which are obviously not correct. I'm new to
coding etc and would much appreciate your help in trying to resolve this
matter. At present i havn't a clue what to dobut i'm sure this is a pretty
easy thing for some of you out there.

Many thanks in advance.

Phil
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top