This is how I got it to work. There are quite a few questions about this floating around on here so I will try to post the link on there discussions.
FOR A DATA ACCESS PAGE! Straight from microsoft.
This will search a single Integer Field for an Integer given by the user and display the corresponding record set. No wildcards allowed in this example.
(A string search will also work with a bit of tweaking)
In design view
1. turn off the controls wizard
2. create a command button and name it cmdSearch
3. go to Tools --> Macro --> Microsoft Script Editor
4. from the Objects and Events box select cmdSearch
5. from the Events box(to the right) select OnClick
6. this will set your cursor in the correct place to insert the following code.
-
' Clone the recordset.
-
-
Dim rs
-
Set rs = MSODSC.DataPages(0).Recordset.Clone
-
On error resume next
-
-
' This line assumes that the value you are filtering on is an integer.
-
' If the search value is a string, use slightly different syntax.
-
' For example, "Field you want to search = '" & CStr(InputBox("Please enter Whatever you want to find", "Find")) & "'"
-
rs.find "[yOUR fIELD HERE]=" & cLng(inputbox("Enter Something to find","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 "No wHATEVER found",,"Search Done"
-
Exit Sub
-
End If
-
MSODSC.DataPages(0).Recordset.Bookmark = rs.Bookmark
-
-->
Hope this helps.
James