Computer Learning Zone CLZ Access Excel Word Windows

No trees were killed to send this message, but a large number of electrons were terribly inconvenienced.

-Neil deGrasse Tyson
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Microsoft Access 320    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
here is my code thx
Kevin 
   
14 years ago
Here is the entire code:

Private Sub Command18_Click()

    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.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Microsoft Access 320.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 5/6/2026 4:41:15 PM. PLT: 1s