Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Help   Contact   Merch   Join   Order   Logon   Forums   
 
Back to Access Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Combo Box to Change Search Field
Neil 

15 years ago
I am trying to put a search function on my database. It is a very small db with only one table that lists equipment part numbers, serial numbers and a few other criteria.

I would like to use a dropdown box to select the field that is to be searched and am unsure how to do it. For the actual search, I have used individual queries for each column to be searched and done a parameter value search (which I found on your website thank you).


Richard Answers:

So you want the drop-down box to have a list of FIELD names in it? That's certainly doable. OK, let's say you want to be able to search on FirstName or LastName. Make a static combo box with just one column and put those values in it. Name the combo box "FieldName". Now make a blank text box called MyParameter where the person will actually type in the value they're looking for.

Now, make a command button with the following code in it:

DoCmd.OpenForm "CustomerForm" ' whatever your customer form is called
Forms!CustomerForm.RecordSource = "SELECT * FROM CustomerTable WHERE " & FieldName & "='" & MyParameter & "'"

When Access compiles that SQL Statement, it will replace the variable names with your data and you'll get something like:

SELECT * FROM CustomerTable WHERE FirstName='Joe'

So the code will open the form and then set the RecordSource property of your form to that SQL statement, basically showing any and all records that meet that criteria.

I cover this in more detail in my Access 311 class:

http://www.599cd.com/site/courselist/access/access311/

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

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: 7/29/2026 4:09:34 PM. PLT: 0s