Thanks for the very quick response.
The table where the data comes from is called "Members"...
Here's the mess!
Private Sub cmdFilter_Click()
If Not IsNull(Me.txtFilterCity) Then
[City] & "([City] = """ & Me.txtFilterCity & """) AND "
End If
If Not IsNull(Me.txtFilterLastName) Then
[LastName] = [LastName] & "([LastName] Like ""*" &
Me.txtFilterLastName & "*"") AND "
End If
If Not IsNull(Me.cboFilterCategory) Then
[Category Name] = [Category Name] & "([Category Name] = " &
Me.cboFilterCategory & ") AND "
End If
If Me.cboFilterBenefits = -1 Then
[Benefits] = [Benefits] & "([Benefits] = True) AND "
ElseIf Me.cboFilterBenefits = 0 Then
[Benefits] = [Benefits] & "([Benefits] = False) AND "
End If
If Not IsNull(Me.txtStartDate) Then
[StartDate] = [StartDate] & "([StartDate] >= " &
Format(Me.txtStartDate) & ") AND "
End If
If Not IsNull(Me.txtStartDate) Then
[StartDate] = [StartDate] & "([StartDate] < " & Format(Me.txtEndDate
+ 1) & ")"
End If
End Sub
There was another post that I can no longer locate that I based the form on
to begin with and tried to amend the code for my form. Didn't do so well as
you can see.
Thanks for your help...
:
If you post your mess, we can try to tidy it up for you, otherwise it's hard
to gauge your level of knowledge, and describing / writing the code for you
from scratch without knowing a single table, field, control, form or button
name is nigh on impossible!!
As a starting guide you would probably be best off having a continuous form
with a row of comboboxes in the form header, and then creating an SQL SELECT
statement to provide the forms recordsource depending on the selections made,
you could use a modified version of this to select the records to be passed
to a Report (only way to print with any control in Access).
hope this gets you started,
TonyT..
:
Trying to create a form to retrieve selected records based on the criteria I
select from a members database. The new form is based on a MainMemberForm and
the citeria I want to search on are: LastName, PostalCode, StartDate, Gender,
JobTitle, and/or MemberID.
I want the form to display the records in a datasheet and then have the
option of printing that data.
I am in over my head with codes and have created nothing but a mess. Can
anyone help?
Thanks