searchable form question

  • Thread starter Thread starter Debbie S.
  • Start date Start date
D

Debbie S.

Hello,
I posted previously in this forum on this question and was answered by
Jeanette Cunningham. Jeanette if you are still out there I have made some
progress and have another question. If anyone else wants to respond that is
fine too of course. I currently have the following code in the click event of
a command filter button in the form:

Private Sub Command4_Click()

If Not IsNull(Me.Text2) Then
strWhere = strWhere & "([City] = """ & Me.Text2 & """) "
End If

End Sub

When I click the button nothing happens. What am I missing?

Thanks,
Debbie
 
Debbie,
What is the name of the textbox control for the field called City?

Jeanette Cunningham
 
Debbie,
there needs to be code tp set the form's filter property.
something like this if Text2 is the name of the textbox control for City.

Private Sub Command4_Click()

If Not IsNull(Me.Text2) Then
strWhere = "([City] = """ & Me.Text2 & """) "

Me.Filter = strWhere
Me.FilterOn = True
Else
Me.FilterOn = False
End If

End Sub

When you add more controls to filter the form, then you will need something
like the code behind that search form on Allen Browne's website.
Post back if you need help to add code for more filter controls.

Jeanette Cunningham
 
Hi! Thanks for responding.
Actually, I finally got the form working with one control, a text box called
City. The reason it did not work before is because I had not included the
code to apply the form's filter (me.filter = strwhere, me.filteron =true). So
that part is fine. But then when I added a second control to the form,
another text box called shipname, the city filter box no longer works (any
city I put in returns a null field), and if I enter criteria into the
shipname box, it gives me the message "no criteria" which is coded into the
filter button as follows:

lngLen = Len (strwhere) - 5
If lngLen <=0 then
msgbox "no criteria", vbinformation, "nothing to do."
Else
strwhere = left$ (strwhere, lngLen)

This is followed by:
me.filter =strwhere
me.filteron=true
end if
end sub

I simply copied the code from the sample database and this is what was in
it. What did I do wrong?

Thanks again,
Debbie

Jeanette Cunningham said:
Debbie,
there needs to be code tp set the form's filter property.
something like this if Text2 is the name of the textbox control for City.

Private Sub Command4_Click()

If Not IsNull(Me.Text2) Then
strWhere = "([City] = """ & Me.Text2 & """) "

Me.Filter = strWhere
Me.FilterOn = True
Else
Me.FilterOn = False
End If

End Sub

When you add more controls to filter the form, then you will need something
like the code behind that search form on Allen Browne's website.
Post back if you need help to add code for more filter controls.

Jeanette Cunningham



Debbie S. said:
Hello,
I posted previously in this forum on this question and was answered by
Jeanette Cunningham. Jeanette if you are still out there I have made some
progress and have another question. If anyone else wants to respond that
is
fine too of course. I currently have the following code in the click event
of
a command filter button in the form:

Private Sub Command4_Click()

If Not IsNull(Me.Text2) Then
strWhere = strWhere & "([City] = """ & Me.Text2 & """) "
End If

End Sub

When I click the button nothing happens. What am I missing?

Thanks,
Debbie
 
Sorry, did not answer this in my last reply: The name of the control is text
2. Having trouble adding a second control.

Jeanette Cunningham said:
Debbie,
What is the name of the textbox control for the field called City?

Jeanette Cunningham


Debbie S. said:
Hello,
I posted previously in this forum on this question and was answered by
Jeanette Cunningham. Jeanette if you are still out there I have made some
progress and have another question. If anyone else wants to respond that
is
fine too of course. I currently have the following code in the click event
of
a command filter button in the form:

Private Sub Command4_Click()

If Not IsNull(Me.Text2) Then
strWhere = strWhere & "([City] = """ & Me.Text2 & """) "
End If

End Sub

When I click the button nothing happens. What am I missing?

Thanks,
Debbie
 
Debbie,
We need to look at how the form is set up. There is something about the form
that is making the filtering very difficult.
If anyone else knows the answer, please jump in.
Debbie would you provide the following:
--name of tables used in the query the form has for its recordsource ( or if
it is a table, the table name)
--name of the primary keys and foreign keys
--the relationships between the tables
--description of which controls you have on the form besides txt2,
txtShipName and Command4

Jeanette Cunningham


Debbie S. said:
Hi! Thanks for responding.
Actually, I finally got the form working with one control, a text box
called
City. The reason it did not work before is because I had not included the
code to apply the form's filter (me.filter = strwhere, me.filteron =true).
So
that part is fine. But then when I added a second control to the form,
another text box called shipname, the city filter box no longer works (any
city I put in returns a null field), and if I enter criteria into the
shipname box, it gives me the message "no criteria" which is coded into
the
filter button as follows:

lngLen = Len (strwhere) - 5
If lngLen <=0 then
msgbox "no criteria", vbinformation, "nothing to do."
Else
strwhere = left$ (strwhere, lngLen)

This is followed by:
me.filter =strwhere
me.filteron=true
end if
end sub

I simply copied the code from the sample database and this is what was in
it. What did I do wrong?

Thanks again,
Debbie

Jeanette Cunningham said:
Debbie,
there needs to be code tp set the form's filter property.
something like this if Text2 is the name of the textbox control for City.

Private Sub Command4_Click()

If Not IsNull(Me.Text2) Then
strWhere = "([City] = """ & Me.Text2 & """) "

Me.Filter = strWhere
Me.FilterOn = True
Else
Me.FilterOn = False
End If

End Sub

When you add more controls to filter the form, then you will need
something
like the code behind that search form on Allen Browne's website.
Post back if you need help to add code for more filter controls.

Jeanette Cunningham



Debbie S. said:
Hello,
I posted previously in this forum on this question and was answered by
Jeanette Cunningham. Jeanette if you are still out there I have made
some
progress and have another question. If anyone else wants to respond
that
is
fine too of course. I currently have the following code in the click
event
of
a command filter button in the form:

Private Sub Command4_Click()

If Not IsNull(Me.Text2) Then
strWhere = strWhere & "([City] = """ & Me.Text2 & """) "
End If

End Sub

When I click the button nothing happens. What am I missing?

Thanks,
Debbie
 
Problem solved. I had copied the code for the second control (shipname) but I
forgot to change the name of the filter control from text2 to text10. It's
working the way it's supposed to now.

I'll keep adding controls--I haven't tried a number or date one yet.
Hopefully I won't need to post again!
Thank you so much for all of your help!!!
Debbie

Jeanette Cunningham said:
Debbie,
We need to look at how the form is set up. There is something about the form
that is making the filtering very difficult.
If anyone else knows the answer, please jump in.
Debbie would you provide the following:
--name of tables used in the query the form has for its recordsource ( or if
it is a table, the table name)
--name of the primary keys and foreign keys
--the relationships between the tables
--description of which controls you have on the form besides txt2,
txtShipName and Command4

Jeanette Cunningham


Debbie S. said:
Hi! Thanks for responding.
Actually, I finally got the form working with one control, a text box
called
City. The reason it did not work before is because I had not included the
code to apply the form's filter (me.filter = strwhere, me.filteron =true).
So
that part is fine. But then when I added a second control to the form,
another text box called shipname, the city filter box no longer works (any
city I put in returns a null field), and if I enter criteria into the
shipname box, it gives me the message "no criteria" which is coded into
the
filter button as follows:

lngLen = Len (strwhere) - 5
If lngLen <=0 then
msgbox "no criteria", vbinformation, "nothing to do."
Else
strwhere = left$ (strwhere, lngLen)

This is followed by:
me.filter =strwhere
me.filteron=true
end if
end sub

I simply copied the code from the sample database and this is what was in
it. What did I do wrong?

Thanks again,
Debbie

Jeanette Cunningham said:
Debbie,
there needs to be code tp set the form's filter property.
something like this if Text2 is the name of the textbox control for City.

Private Sub Command4_Click()

If Not IsNull(Me.Text2) Then
strWhere = "([City] = """ & Me.Text2 & """) "

Me.Filter = strWhere
Me.FilterOn = True
Else
Me.FilterOn = False
End If

End Sub

When you add more controls to filter the form, then you will need
something
like the code behind that search form on Allen Browne's website.
Post back if you need help to add code for more filter controls.

Jeanette Cunningham



Hello,
I posted previously in this forum on this question and was answered by
Jeanette Cunningham. Jeanette if you are still out there I have made
some
progress and have another question. If anyone else wants to respond
that
is
fine too of course. I currently have the following code in the click
event
of
a command filter button in the form:

Private Sub Command4_Click()

If Not IsNull(Me.Text2) Then
strWhere = strWhere & "([City] = """ & Me.Text2 & """) "
End If

End Sub

When I click the button nothing happens. What am I missing?

Thanks,
Debbie
 
So pleased you got is working, we love to be able to help.

Jeanette Cunningham

Debbie S. said:
Problem solved. I had copied the code for the second control (shipname)
but I
forgot to change the name of the filter control from text2 to text10. It's
working the way it's supposed to now.

I'll keep adding controls--I haven't tried a number or date one yet.
Hopefully I won't need to post again!
Thank you so much for all of your help!!!
Debbie

Jeanette Cunningham said:
Debbie,
We need to look at how the form is set up. There is something about the
form
that is making the filtering very difficult.
If anyone else knows the answer, please jump in.
Debbie would you provide the following:
--name of tables used in the query the form has for its recordsource ( or
if
it is a table, the table name)
--name of the primary keys and foreign keys
--the relationships between the tables
--description of which controls you have on the form besides txt2,
txtShipName and Command4

Jeanette Cunningham


Debbie S. said:
Hi! Thanks for responding.
Actually, I finally got the form working with one control, a text box
called
City. The reason it did not work before is because I had not included
the
code to apply the form's filter (me.filter = strwhere, me.filteron
=true).
So
that part is fine. But then when I added a second control to the form,
another text box called shipname, the city filter box no longer works
(any
city I put in returns a null field), and if I enter criteria into the
shipname box, it gives me the message "no criteria" which is coded into
the
filter button as follows:

lngLen = Len (strwhere) - 5
If lngLen <=0 then
msgbox "no criteria", vbinformation, "nothing to do."
Else
strwhere = left$ (strwhere, lngLen)

This is followed by:
me.filter =strwhere
me.filteron=true
end if
end sub

I simply copied the code from the sample database and this is what was
in
it. What did I do wrong?

Thanks again,
Debbie

:

Debbie,
there needs to be code tp set the form's filter property.
something like this if Text2 is the name of the textbox control for
City.

Private Sub Command4_Click()

If Not IsNull(Me.Text2) Then
strWhere = "([City] = """ & Me.Text2 & """) "

Me.Filter = strWhere
Me.FilterOn = True
Else
Me.FilterOn = False
End If

End Sub

When you add more controls to filter the form, then you will need
something
like the code behind that search form on Allen Browne's website.
Post back if you need help to add code for more filter controls.

Jeanette Cunningham



Hello,
I posted previously in this forum on this question and was answered
by
Jeanette Cunningham. Jeanette if you are still out there I have made
some
progress and have another question. If anyone else wants to respond
that
is
fine too of course. I currently have the following code in the click
event
of
a command filter button in the form:

Private Sub Command4_Click()

If Not IsNull(Me.Text2) Then
strWhere = strWhere & "([City] = """ & Me.Text2 & """) "
End If

End Sub

When I click the button nothing happens. What am I missing?

Thanks,
Debbie
 
Back
Top