Need help building query into form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a very simple table with my distributors in it ( firstname, lastname,
address, city, state, zip and 2 checkboxes) what I would like to be able to
do is have a "query" textbox on one of my forms so that i can type in a field
to search for such as locating all distributors that live in houston and have
it pull up all pertinent fields for those distributors that live in houston.
 
You can use a form with the text box in the header. Add code to the after
udpate event of the text box like:

Dim strWhere as String
strWhere = "1=1 "
If Not IsNull(Me.txtCity) Then
strWhere = strWhere & " AND [city] ='" & _
Me.txtCity & "' "
End If
If Len(strWhere) > 4 Then
Me.Filter = strWhere
End If
Me.FilterOn = Len(strWhere) > 4
 
ok you're going to have to break it down more than this. i added the code but
when i try the text box in the form i get the VB window popping up saying
compile error: method or data member not found. and ".txtCity" was
highlighted.

I just want to make clear that i cannot code myself to the bathroom.

if you could like step by step me thru this i would greatly appreciate it.


Duane Hookom said:
You can use a form with the text box in the header. Add code to the after
udpate event of the text box like:

Dim strWhere as String
strWhere = "1=1 "
If Not IsNull(Me.txtCity) Then
strWhere = strWhere & " AND [city] ='" & _
Me.txtCity & "' "
End If
If Len(strWhere) > 4 Then
Me.Filter = strWhere
End If
Me.FilterOn = Len(strWhere) > 4

--
Duane Hookom
Microsoft Access MVP


SodiumSlayer said:
I have a very simple table with my distributors in it ( firstname, lastname,
address, city, state, zip and 2 checkboxes) what I would like to be able to
do is have a "query" textbox on one of my forms so that i can type in a field
to search for such as locating all distributors that live in houston and have
it pull up all pertinent fields for those distributors that live in houston.
 
"txtCity" should reference the name of your text box that users enter their
search value into. If your text box has a different name, either change the
code or change the control name.

--
Duane Hookom
Microsoft Access MVP


SodiumSlayer said:
ok you're going to have to break it down more than this. i added the code but
when i try the text box in the form i get the VB window popping up saying
compile error: method or data member not found. and ".txtCity" was
highlighted.

I just want to make clear that i cannot code myself to the bathroom.

if you could like step by step me thru this i would greatly appreciate it.


Duane Hookom said:
You can use a form with the text box in the header. Add code to the after
udpate event of the text box like:

Dim strWhere as String
strWhere = "1=1 "
If Not IsNull(Me.txtCity) Then
strWhere = strWhere & " AND [city] ='" & _
Me.txtCity & "' "
End If
If Len(strWhere) > 4 Then
Me.Filter = strWhere
End If
Me.FilterOn = Len(strWhere) > 4

--
Duane Hookom
Microsoft Access MVP


SodiumSlayer said:
I have a very simple table with my distributors in it ( firstname, lastname,
address, city, state, zip and 2 checkboxes) what I would like to be able to
do is have a "query" textbox on one of my forms so that i can type in a field
to search for such as locating all distributors that live in houston and have
it pull up all pertinent fields for those distributors that live in houston.
 

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

Back
Top