I am trying to add a filter into my form code with no success. The simple Select statement works fine but I cannot get it into my code. The statement is:
Code:
SELECT * FROM CalendarTbl WHERE Type <> "Pers" OR Type <> "House" OR Type <> "Gen" ORDER BY EventDay DESC;
The code right now that works is:
Code:
Private Sub RequeryForm()
Dim W As String
Dim S As String
W = ""
If Not IsNull(StartDate) Then
If W <> "" Then W = W & " AND "
W = W & "EventDay >= #" & StartDate & "#"
End If
If Not IsNull(EndDate) Then
If W <> "" Then W = W & " AND "
W = W & "EventDay <= #" & EndDate & "#"
Me.lblTimer.Caption = "All Items in Date Range"
End If
If Done = True Then
If W <> "" Then W = W & " AND "
W = W & "Complete = True"
Me.lblTimer.Caption = "Completed Items in Date Range"
ElseIf Done = False Then
If W <> "" Then W = W & " AND "
W = W & "Complete = False"
Me.lblTimer.Caption = "Pending Items in Date Range"
End If
S = "Select * FROM CalendarTbl"
If W <> "" Then S = S & " WHERE " & W
Me.RecordSource = S & " ORDER BY [EventDay] DESC"
End Sub
I though I could just modify the WHERE clause to:
Code:
If W <> "" Then S = S & " WHERE Type <> 'Pers' OR Type <> 'House' OR Type <> 'Gen' " & W
But that does not work. I would like to learn how to add this type of filter so any help would be greatly appreciated.
Thanks
Jim O