Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Search Form 2.0    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Search Two Fields
Matthew McHenry 
    
4 years ago
I am trying to look up customer by phone number. In CustomerT there are PhoneNumber1 and PhoneNumber2. Is there way in VBA to search both fields just using one "search box"?

I am still in the deigning phase of my Database so I'm not against putting all the PhoneNumber in their own Table.
Kevin Robertson  @Reply  
          
4 years ago
You could do something like this.
WhereStr = WhereStr & "PhoneNumber1 LIKE ""*" & txtSearch & "*"" OR PhoneNumber2 LIKE ""*" & txtSearch & "*"""
Matthew McHenry OP  @Reply  
    
4 years ago
I think I mess up " somewhere

    
    If PhoneNumberSearch <> "" Then
        If WhereStr <> "" Then WhereStr = WhereStr & " AND "
        WhereStr = WhereStr & "PhoneNumber1 LIKE ""*" & PhoneNumberSearch & "*""" Or "PhoneNumber2 Like""*" & PhoneNumberSearch & "*"""
    End If
Adam Schwanz  @Reply  
           
4 years ago
Look at what's different in yours and Kevins.

You have an extra quotation in the middle. It doesn't need "*""" in the middle, it only has that extra " at the end to close the statement.
Adam Schwanz  @Reply  
           
4 years ago
One of the most confusing things is the quotations. Just remember everytime you start with a ", you are opening a statement, and at the end of the statement you need another " to close it.
Matthew McHenry OP  @Reply  
    
4 years ago
Fount them both the way I had it PhoneNumber2 was a txt str not a feild to be search.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Search Form 2.0.
 

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/5/2026 6:25:12 PM. PLT: 1s