Query based on criteria in two fields?

MrCee

New member
Local time
Tomorrow, 04:13
Joined
Sep 4, 2007
Messages
5
Hi All

I want to create a query which is based on two fields.

One field is a date query i.e >=Date()-7 OR >=Date+7

The Other is a Combo box where the criteria is No

My problem is that access is currently running this as two individual queries.

Is it possible to make this query return data only when both fields are matching?

Or do I have to run this as a parameter query?

Thanks!!
 
Your Where clause should look something like this:

WHERE (MyDateField BETWEEN (Date()-7) AND (Date()+7)) AND MyOtherField = "No"
 
When I ran a subform query for two criteria this is what I got:

Code:
    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "frmAuditProcessWork"
 
    stLinkCriteria = "[Supervisor]=" & "'" & Me![SupervisorNameBox] & "'" & " AND " & "Month([LogDate])=" & "'" & Month(Me![Audit Month]) & "'"
    DoCmd.OpenForm stDocName, , , stLinkCriteria

SupervisorNameBox is an unbound input field, and so is AuditMonth.

Supervisor and LogDate are fields in the table.

This is in the On Click event where a button is clicked to perform the Audit.

Only the records for the particular supervisor are pulled from the total records and only the month they wish to audit are pulled up.
 

Users who are viewing this thread

Back
Top Bottom