use vba to find a record on my form searching all phone fields in

J

jjbra

Hi,
I Am Trying to search a table that has three phone fields, I want to
have the user type in one phone number and be able to select it and have
access put that record on my form.

Can you help me ?

Thanks in
Advance
 
J

John Vinson

Hi,
I Am Trying to search a table that has three phone fields, I want to
have the user type in one phone number and be able to select it and have
access put that record on my form.

Can you help me ?

Thanks in
Advance

You don't really need much (or any!) VBA to do this.

Put an unbound textbox named txtFindPhone on your Form. Create a Query
based on your table. Put

[Forms]![YourFormName]![txtFindPhone]

on the Criteria line under HomePhone, WorkPhone, CellPhone (or
whatever the fields are), on three separate lines - so it will use OR
logic to find it in any one of the fields; and include all the other
fields you want to see in the query.

The one snippet of VBA would be in txtFindPhone's AfterUpdate event:

Private Sub txtFindPhone_AfterUpdate()
Me.Recordsource = "YourQueryName"
End Sub

John W. Vinson[MVP]
 
Top