Search textboxes on a form

G

Guest

I am creating a employee database. i have a main form that different shifts
can enter employee information. i would like to include a textbox on the
form to use for a search box where they would type the employee last name,
employee#, etc - push a button and the records appears on the form. Sort of
like a filter. How do I go about building this? I am sort of new at this.
 
B

bballpinhead

Here is what i have done. User enters in data into the text box and
clicks a find button. then the below code executes.
If Me![txtFindCustomer] <> "" Then
Me.FilterOn = False
Me.Filter = "[Customer] Like '" & "*" & Me![txtFindCustomer] & "*"
& "'"
Me.FilterOn = True
Me.cmdUnlock.Visible = False
Me.lblTitle.Caption = "Viewing: " & Me![txtFindCustomer]
End If
this will allow the user to find data that is like their entry but does
not have to be exact
you can have a multiple type search by having more than one text box
and editing the filter as necessary
 
G

Guest

OK. Thank you. I will try that. But where do I put the code? Of course I
have the textbox and then a find button. Do I put the code on the OnClick of
the button? I've read other answers that mentioned putting the code in the
AfterUpdate property.

bballpinhead said:
Here is what i have done. User enters in data into the text box and
clicks a find button. then the below code executes.
If Me![txtFindCustomer] <> "" Then
Me.FilterOn = False
Me.Filter = "[Customer] Like '" & "*" & Me![txtFindCustomer] & "*"
& "'"
Me.FilterOn = True
Me.cmdUnlock.Visible = False
Me.lblTitle.Caption = "Viewing: " & Me![txtFindCustomer]
End If
this will allow the user to find data that is like their entry but does
not have to be exact
you can have a multiple type search by having more than one text box
and editing the filter as necessary
kr said:
I am creating a employee database. i have a main form that different shifts
can enter employee information. i would like to include a textbox on the
form to use for a search box where they would type the employee last name,
employee#, etc - push a button and the records appears on the form. Sort of
like a filter. How do I go about building this? I am sort of new at this.
 
B

bballpinhead

You will want to put it on the click event. If you were using a combo
drop down then use the after update
kr said:
OK. Thank you. I will try that. But where do I put the code? Of course I
have the textbox and then a find button. Do I put the code on the OnClick of
the button? I've read other answers that mentioned putting the code in the
AfterUpdate property.

bballpinhead said:
Here is what i have done. User enters in data into the text box and
clicks a find button. then the below code executes.
If Me![txtFindCustomer] <> "" Then
Me.FilterOn = False
Me.Filter = "[Customer] Like '" & "*" & Me![txtFindCustomer] & "*"
& "'"
Me.FilterOn = True
Me.cmdUnlock.Visible = False
Me.lblTitle.Caption = "Viewing: " & Me![txtFindCustomer]
End If
this will allow the user to find data that is like their entry but does
not have to be exact
you can have a multiple type search by having more than one text box
and editing the filter as necessary
kr said:
I am creating a employee database. i have a main form that different shifts
can enter employee information. i would like to include a textbox on the
form to use for a search box where they would type the employee last name,
employee#, etc - push a button and the records appears on the form. Sort of
like a filter. How do I go about building this? I am sort of new at this.
 
G

Guest

Thank you...thank you! That's clears it up. Also, is there a way to
reference all the fields without using multiple boxes?

bballpinhead said:
You will want to put it on the click event. If you were using a combo
drop down then use the after update
kr said:
OK. Thank you. I will try that. But where do I put the code? Of course I
have the textbox and then a find button. Do I put the code on the OnClick of
the button? I've read other answers that mentioned putting the code in the
AfterUpdate property.

bballpinhead said:
Here is what i have done. User enters in data into the text box and
clicks a find button. then the below code executes.
If Me![txtFindCustomer] <> "" Then
Me.FilterOn = False
Me.Filter = "[Customer] Like '" & "*" & Me![txtFindCustomer] & "*"
& "'"
Me.FilterOn = True
Me.cmdUnlock.Visible = False
Me.lblTitle.Caption = "Viewing: " & Me![txtFindCustomer]
End If
this will allow the user to find data that is like their entry but does
not have to be exact
you can have a multiple type search by having more than one text box
and editing the filter as necessary
kr wrote:
I am creating a employee database. i have a main form that different shifts
can enter employee information. i would like to include a textbox on the
form to use for a search box where they would type the employee last name,
employee#, etc - push a button and the records appears on the form. Sort of
like a filter. How do I go about building this? I am sort of new at this.
 
B

bballpinhead

Me.Filter = "[Customer] Like '" & "*" & Me![txtFindCustomer] AND
[Customer2] Like '" & "*" & Me![txtFindCustomer2]"
This should work. You can add as many as you want to refrence.
HTH

Thank you...thank you! That's clears it up. Also, is there a way to
reference all the fields without using multiple boxes?

bballpinhead said:
You will want to put it on the click event. If you were using a combo
drop down then use the after update
kr said:
OK. Thank you. I will try that. But where do I put the code? Of course I
have the textbox and then a find button. Do I put the code on the OnClick of
the button? I've read other answers that mentioned putting the code in the
AfterUpdate property.

:

Here is what i have done. User enters in data into the text box and
clicks a find button. then the below code executes.
If Me![txtFindCustomer] <> "" Then
Me.FilterOn = False
Me.Filter = "[Customer] Like '" & "*" & Me![txtFindCustomer] & "*"
& "'"
Me.FilterOn = True
Me.cmdUnlock.Visible = False
Me.lblTitle.Caption = "Viewing: " & Me![txtFindCustomer]
End If
this will allow the user to find data that is like their entry but does
not have to be exact
you can have a multiple type search by having more than one text box
and editing the filter as necessary
kr wrote:
I am creating a employee database. i have a main form that different shifts
can enter employee information. i would like to include a textbox on the
form to use for a search box where they would type the employee last name,
employee#, etc - push a button and the records appears on the form. Sort of
like a filter. How do I go about building this? I am sort of new at this.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top