Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

HELP! Coding Problem With Search Button

Discussion in 'Information Technology' started by Phil, Nov 11, 2005.

  1. Phil

    Expand Collapse

    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

    <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

    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.

  2. Loading...

Since you're here... we have a small favor to ask...     Become a Supporter      ::     Make a Contribution     

Share This Page