Dim db As Database Dim rs As Recordset Dim MySQL As String
Status "---------"
Set db = CurrentDb Set rs = db.OpenRecordset("CustomerT", dbOpenDynaset)
MySQL = " " If Not IsNull(FirstName) Then MySQL = "FirstName LIKE '*" & FirstName & "*'" End If
If Not IsNull(LastName) Then If MySQL <> "" Then MySQL = MySQL & " AND " End If MySQL = MySQL & "LastName LIKE '*" & LastName & "*'" End If
If Not IsNull(Age) Then If MySQL <> "" Then MySQL = MySQL & " AND " End If MySQL = MySQL & "Age " & AgeEq & " " & Age End If
If MySQL = "" Then Exit Sub
Counter = 0 rs.FindFirst MySQL
Do While rs.NoMatch = False Status "FOUND: " & rs!FirstName & " " & rs!LastName & " " & rs!Age Counter = Counter + 1 rs.FindNext MySQL Loop
If Counter = 0 Then Status "No Match Found" End If
Set db = Nothing Set rs = Nothing
End Sub
I even tried replacing the with:
MySQL = MySQL & "Age >= 20" & Age
but that didn't work either. I double checked that I created the combo box the same as the video. Does this have anything to do with the fact I am using 2010? Why does the debug feature highlight the "rs.FindFirst MySQL" line
Thanks Rick. I love all the courses and appreciate how fast you get back to me. Happy St. Pat's day!
Reply from Richard Rost:
Your SQL looks fine... except you wouldn't want to say:
MySQL = MySQL & "Age >= 20" & Age
This should be just:
MySQL = MySQL & "Age >= 20"
No need to add on Age to the end of that again. Can you send me your database? ZIP it up and email it to [email protected]. Remove any sensitive data.
Sorry, only students may add comments.
Click here for more
information on how you can set up an account.
If you are a Visitor, go ahead and post your reply as a
new comment, and we'll move it here for you
once it's approved. Be sure to use the same name and email address.
This thread is now CLOSED. If you wish to comment, start a NEW discussion in
Microsoft Access 320.