473,472 Members | 2,241 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

One button to search multiple fields on a form

4 New Member
Hi there, I have a form that allows for 3 mobile contact numbers. I understand how to create a search button that will open the specific record to display the data when only one field is being used in the search.

Is it possible to have the command button search Mobile1, Mobile2 and Mobile3 and return the record that contains the number?

I hope I'm making sense here and thanks in advance.
Dec 20 '16 #1
1 5767
gnawoncents
214 New Member
If you are asking what I think you are, the answer is yes. Here is what I think you want (If not, please clarify):

Three fields with data
Mobile 1: 5555555555
Mobile 2: 1111111111
Mobile 3: 2222222222

If you want to find the record that has 2222222222 as a mobile contact number but do not care which of the three fields it is in, you could use code similar to the example below.

This code assumes the form is already connected to the source table and executes when a button (btnSearchNumber) is pressed. The search for information is entered into a text field named txtNumber but could easily be swapped for an input box or something else.

Expand|Select|Wrap|Line Numbers
  1. Private Sub btnSearchNumber_Click()
  2.  
  3. 'Use phone number entered into field "txtNumber" as search criteria
  4. Dim strSearchNumber As String
  5. strSearchNumber = Me.txtNumber
  6.  
  7. Dim strGoToRecord As String
  8.  
  9. Dim rst As Recordset
  10. Set rst = Me.RecordsetClone
  11. rst.MoveFirst
  12.  
  13. 'Find the first record that matches the search number in Mobile1, 2, or 3
  14. strGoToRecord = "[Mobile1] = " & strSearchNumber _
  15. & " OR [Mobile2] = " & strSearchNumber _
  16. & " OR [Mobile3] = " & strSearchNumber
  17. rst.FindFirst strGoToRecord
  18.  
  19. Set rst = Nothing
  20.  
  21. End Sub
  22.  
Dec 28 '16 #2

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

Similar topics

2
by: michael nieuwenhuizen | last post by:
how do i create a sticky form with multiple fields? say i want a form with: name: address: country: and if a user presses the submit button it will show
6
by: Rizyak | last post by:
******************** alt.php.sql,comp databases.ms-sqlserver microsoft.public.sqlserver.programming *********************************** Why doesn't this work: SELECT * FROM 'Events'
4
by: Martin Lacoste | last post by:
(Access 2000) Two issues: Within a query, I need to return a field name as data (see eg. below). I need to search within 80 fields (same criteria) - is there a way to avoid 80 separate...
3
by: IP This | last post by:
Good Day Good People... I have a table with various fields, a number of fields relate to the same data type, i.e. Language1, Language2, Language3, Language4, - I want to be able to search all of...
0
by: Alex Pavluck | last post by:
Hello. I need to search 6 different fields for a key word. The way I normally query data is in a single field with the critera: Like '*' & & '*'. Is there a way to enter only 1 key word but...
10
by: Eugenio | last post by:
Hi there, I'm returning to this forum for the second time and I would like to say thanks for the great help provided. I've encountered a new problem now and hope that you will be able to help me...
1
by: Lyn DeMaio | last post by:
I've been tasked with taking two unrealted tables (Providers and Patients, no common field) and allow users, on one form (or form/subform) to search multiple fields in each table, select a record...
32
LeighW
by: LeighW | last post by:
Hi, I'm still having a couple problems with searches. I have a search form, frm_Search. The form I am trying to filter, frm_Form1 An unbound combobox on frm_Search, Cbo_Permit 6 different...
2
by: deanvilar | last post by:
Need your help once again guys ... I have 4 serial description and 4 serial number fields, if I search for 1 serial description and 1 serial number it's not a problem .. but i cant figure out how...
2
by: Pranish01 | last post by:
I am using Ms Access 2013 and the resource for the search is taken from http://www.iaccessworld.com/how-to-create-search-form/ The supplier table(tblSupplier) with fields (SupplierID , Company ,...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.