Find Button

G

Guest

Hello, I got help with this question before. I'm trying to make a find button in Access 2002 that can search in 2 fields at the same time. Here is my code, most of which a nice gentleman Pavel helped me with. However, when I click the button the standard office find window opens and generates a "Syntax error (missing operator) in expression." I was wondering if it is possible in access to create a message box that allows a user to search in two fields, or help with manipulating the current code to searching in 2 fields. Any amount of help would be greatly appreciated

Private Sub testfind_Click(
On Error GoTo Err_testfind_Clic

Screen.PreviousControl.SetFocu
DoCmd.DoMenuItem acFormBar, acEditMenu, 10, , acMenuVer7

Me.Form.RecordsetClone.FindFirst "Loader Name = " & SearchCriteri

If Me.Loader_Name The
Me.Form.RecordsetClone.FindFirst "Date = " & SearchCriteri
End I

Me.Form.RecordsetClone.Bookmar

Exit_testfind_Click
Exit Su

Err_testfind_Click
MsgBox Err.Descriptio
Resume Exit_testfind_Clic

End Su

Thank you

Marat Mamedov
 
P

Pavel Romashkin

I have no idea what the first two lines of your code are supposed to do.
I'd try:

Private Sub testfind_Click()
On Error Resume next
Dim SearchCriteria as String
'Set SearchCriteria to the right value here:
SearchCriteria = Me.Form.txtSearchCriteria
Me.Form.RecordsetClone.FindFirst "Loader Name = '" & SearchCriteria
& "'"
If Me.Form.RecordsetClone.EOF Then
Me.Form.RecordsetClone.FindFirst "Date = #" & SearchCriteria & "#"
End If
If Not Me.Form.RecordsetClone.EOF Then
Me.Form.Recordset.Bookmark = Me.Form.RecordsetClone.Bookmark
Else
MsgBox, "No matching records found"
End if
End Sub

txtSearchCriteria is a text box on your form that you enter the search
value into.
If you need to search both fields *at the same time*, or concatinate
them, it will certainly be different.
Good luck,
Pavel
 

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

Similar Threads

Event Procedure help 2
List Box Selected Item 3
Find Button 1
Error 2237 8
Comand Button 2
"Delete Record" command button woes 4
vba coding 4
Modifying Command Button 2

Top