Using Text Box to Search

Larsporsenna

Registered User.
Local time
Today, 02:13
Joined
Aug 20, 2013
Messages
17
I have 2 tables ASSETS and GENERAL PRACTICES and 2 corresponding Forms. In the Assets Form I have set up a text box and used a command button to let the user search for a particular Asset. The code I used for the on click event was
Private Sub SearchBox_Click()
Dim strSearch As String
On Error GoTo errHandler
strSearch = "Asset_Id = " & Chr(39) & Me!Text67.Value & Chr(39)
Me.RecordsetClone.FindFirst strSearch
Me.Bookmark = Me.RecordsetClone.Bookmark
Exit Sub
errHandler:
MsgBox "Error No: " & Err.Number & "; Description: " & _
Err.Description
End Sub

This works fine and when I click I find the correct Asset. I have used the same technique on the GP Form but when I click on the search Button I get the error message “Error No 30077 Description Syntax Error (Missing operator) in expression.
I copied the code and edited to suit the different names
Private Sub Find_Practice_Click()
Dim strSearch As String
On Error GoTo errHandler
strSearch = "Practice Code Regional = " & Chr(39) & Me!Text5.Value & Chr(39)
Me.RecordsetClone.FindFirst strSearch
Me.Bookmark = Me.RecordsetClone.Bookmark
Exit Sub
errHandler:
MsgBox "Error No: " & Err.Number & "; Description: " & _
Err.Description
End Sub
I can’t see what I am doing differently. Can anyone help? I am using Acess 2007
 
For starters, the inadvisable spaces in the field name require it to be bracketed.
 
It's a database that I have inherited and the naming conventions are all over the place or rather non-existent (there's one field called "System / Version"). I changed the name to Practice_Code_Regional and it worked.
Looks Like I'm going to have to change a few more.
Thanks.
 
No problem. Like I said, the work around is brackets:

[Practice Code Regional]
 

Users who are viewing this thread

Back
Top Bottom