By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,098 Members | 1,950 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,098 IT Pros & Developers. It's quick & easy.

One command button to search multiple fields on a form

P: 4
Hi there,

I have a form that allows for three mobile numbers. I understand how to create a search button that will open the form and display the record when only one field is being searched however, I need my search to look at all three fields (mobile1, mobile2 and mobile3) and open the form to display the relevant record.

Is this possible at all?

Thanks in advance.
Dec 20 '16 #1
Share this Question
Share on Google+
4 Replies

Expert 100+
P: 1,430
I suspect it is comparatively simply. Basically you build a filter and apply it to the form. You don't even need a command button to apply the filter, that can be done ob the AfterUpdate of the search mobile number, but you may prefer a command button to remove the filter.

First some questions.
Is the mobile number a text field?
If so, do you use spaces in your mobile number in your table (I'm not interested in the way it's displayed)?
Are you looking for an exact match only or a partial match (for example if you type "57912" into your search box do you want all records with those numbers somewhere within the mobile numbers?

Dec 21 '16 #2

P: 4
Hi Phil,

Thanks for your reply.

Yes, the mobile number is a text field.

No spaces.

Exact match.
Dec 21 '16 #3

Expert 100+
P: 1,430
Hi Sally

Try this

Create an unbound text box on your form called "TxtSearchMobile"
Then on the after update of TxtSearchMobile try this code:-

Expand|Select|Wrap|Line Numbers
  1. Private Sub TxtSearchMobile_AfterUpdate()
  2.     Dim Fltr as String
  4.     Fltr = "Mobile1 = " & Chr$(34) & TxtSearchMobile & Chr$(34)
  5.     Fltr = Fltr & " OR Mobile2 = " & Chr$(34) & TxtSearchMobile & Chr$(34)
  6.     Fltr = Fltr & " OR Mobile3 = " & Chr$(34) & TxtSearchMobile & Chr$(34)
  8.     Me.Filter = Fltr
  9.     Me.FilterOn = True
  10.     Me.Requery
  12. End Sub
Dec 21 '16 #4

P: 4
Hi Phil,

Sorry for the delayed response - thank you kindly :)

I'm between stops but will get back to you asap with what I'm sure will be positive results.

Thanks again!
Dec 21 '16 #5

Post your reply

Sign in to post your reply or Sign up for a free account.