Here's a sample of the code I used in one recent query form. It gives the user the chance to query varying six or seven different criteria. This code builds the SQL string out of the settings on the form. It's helpful (should be obvious) to first experiment by constructing a number of representative actual queries. They'll give you a feel for what you need to incorporate into the query form. This code builds the SQL string out of the settings on the form:
-----------------------------------------------
Dim strWhere As String
Dim strHAVING As String
Dim strSQL2 As String
strSQL = "SELECT DISTINCT tblMTS.uniqueid, " & IIf(Me.cboCampaign > 0, "[Donor Contributions].FundrID,", ""

_
& " sum([Donor Contributions].DonorAmount) as sumofdonoramount " _
& " FROM tblMTS LEFT JOIN [Donor Contributions] ON tblMTS.uniqueid = [Donor Contributions].PersonID "
If Not IsNull(Me.cboKind) Then
If Me.cboKind <> "Non In Kind" Then
strWhere = " AND ([Donor Contributions].lngDonationtype = '" & Me.cboKind & "')"
Else
strWhere = " AND ([Donor Contributions].lngDonationtype <> 'In Kind')"
End If
End If
If Me.cboCampaign > 0 Then
strHAVING = strHAVING & " AND ([Donor Contributions].FundrID = " & Me.cboCampaign & "

"
End If
If Not IsNull(Me.txtMoreThan) Then
strHAVING = strHAVING & " AND (sum([Donor Contributions].DonorAmount) >= " & Me.txtMoreThan & "

"
End If
If Not IsNull(Me.txtLessThan) Then
strHAVING = strHAVING & " AND (sum([Donor Contributions].DonorAmount) <= " & Me.txtLessThan & "

"
End If
If Not IsNull(Me.txtBeginDate) Then
strWhere = strWhere & " AND ([Donor Contributions].DonorDate >= #" & Me.txtBeginDate & "#)"
End If
If Not IsNull(Me.txtEndDate) Then
strWhere = strWhere & " AND ([Donor Contributions].DonorDate <= #" & Me.txtEndDate & "#)"
End If
If strWhere <> "" Then
strWhere = " WHERE " & Mid(strWhere, 6)
End If
If strHAVING <> "" Then
strHAVING = " HAVING " & Mid(strHAVING, 6)
End If
strSQL2 = "GROUP BY tblMTS.uniqueid" & IIf(Not IsNull(Me.cboCampaign), ", [Donor Contributions].FundrID", ""
strSQL = strSQL & strWhere & strSQL2 & strHAVING
-------------------------------------------------------