Searching Options

popeye

Work smarter, not harder.
Local time
Today, 03:48
Joined
Aug 23, 2004
Messages
75
i would like to create a search form that searches based on three criterias\

1. If both Surname and Firstname are entered where firstname's displayed are dependent on the firstname selected

2. Search by firstname only

3. search by surname only.

I can create this by using several forms and multiple textbox.

Can someone help me or post a example of a search form that will do somethhing close to what i need. Just need to get an idea. :confused:

I wwould like to create one that has 2 text boxs one for surnam,e and one for firstname. with three searcxh buttons.

I figure more or less that someone has had to do something similar to this one already.
Please help. :confused:
 
Last edited:
What I have done is

I just made one TextBox

and whatever the user typed in, Search it in both First name and Lastname


Sample Code

Private Sub Search()
ListCustomer.RowSource = _
"SELECT AccountNo, Company, Contact " & _
"FROM tblCustomerTemp " & _
"WHERE ((tblCustomerTemp.Company LIKE '*" & TextSearchCustomer.Value & "*') OR (tblCustomerTemp.Company Is Null AND (tblCustomerTemp.Contact LIKE '*" & TextSearchCustomer.Value & "*'))) " & _
"OR ((tblCustomerTemp.Contact LIKE '*" & TextSearchCustomer.Value & "*') OR (tblCustomerTemp.Contact Is Null AND (tblCustomerTemp.Company LIKE '*" & TextSearchCustomer.Value & "*'))) " & _
"ORDER BY COMPANY, CONTACT;"
End Sub
 
Thanks , one more thing though.

was that text box placced on the same form that has the information to display?

Did you use any kind of command button.

Where does the code go. Does it go to an onclick or on enter event?
 
Q. was that text box placced on the same form that has the information to display?
A. My information was on a Listbox and the text box was on the same form

Q. Did you use any kind of command button.
A. Nop

Q. Where does the code go. Does it go to an onclick or on enter event?
A. Textbox_AfterUpdate()
 
the information that i have is on a form. not a list box.

and one more thing pat, what does the _ at the end of some of your lines mean.

Im not new to access per say, but i am new to vb.

weird right. :cool:
 
if it is a form then you can filter the form

Textbox_AfterUpdate()
me.filter = "[Firstname] LIKE '*" & nz(Textbox.value, "") & "*' AND " & _
"[Lastname] LIKE '*" & nz(Textbox.value, "") & "*'"
me.filteron = true
End Sub

EX : [Firstname] LIKE '*jeff*' AND [Lastname] LIKE '*jeff*'

_ <-- this thing
it allows you to continue your code on the next line in VB.

EX:
If ( a = b ) AND ( b = c ) AND ( a <> d ) Then Exit Sub

you can change it to

If ( a = b ) AND _
( b = c ) AND _
( a <> d) _
Then Exit Sub
 

Users who are viewing this thread

Back
Top Bottom