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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with FIND/SEARCHING script in Data Access Page

Status
Not open for further replies.

dragonmanUSMC

IS-IT--Management
Dec 10, 2004
31
Hello, I have a script that will allow the user to search our database from a data access page for a company. (search is by CompanyName)

Here is the problem: The script only works after you have created a new company entry in the database. If you try to run the FIND script without entering new company info nothing happens, but it works fine as soon after. If you exit the DAP and come back later you have to repeat the process of entering new company data

Here is the script any help in why this doesn't work as soon as you launch the DAP would be greatly appreciated:

<SCRIPT language=vbscript event=onclick for=Command0>

<!--

Dim rs
Set rs = MSODSC.DataPages(0).Recordset.Clone

On error resume next
rs.find "CompanyName= '" & Cstr(InputBox("Please Enter A Company Name To Begin Searching The Customer Database", "Find")) & "'"

If (err.number <> 0) Then
Msgbox "Error: " & err.number & " " & err.Description,, "Invalid Search"
Exit Sub
End if

If (rs.bof) or (rs.eof) Then
Msgbox "I'm Sorry But That Company Does Not Appear To Be In The Customer Database",,"Done Searching"
Exit Sub
End if

MSODSC.DataPages(0).Recordset.Bookmark = rs.Bookmark
-->
</SCRIPT>
 
I am working on something similar. You can see my posting and the answer a few lines up under

Adding Command Button to Search Access Page
 
And here it is if you can't fing the post


<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 "Description Like '%" & CStr(inputbox("Enter a Key Word","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 "Word Not Found",,"Search Done"
Exit Sub
End If
MSODSC.DataPages(0).Recordset.Bookmark = rs.Bookmark
-->
</SCRIPT>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top