CoffeeLover
New member
- Local time
- Yesterday, 23:25
- Joined
- Aug 5, 2015
- Messages
- 6
Hello!
I am having trouble filtering my report.
My goal is to filter the report by:
1) [DateChanged] by user entry on a form (txtFrom and txtTo)
2)[Deliverable] by selection of a list box on form
My error is in the last line when i open the report.
it only lets me filter using either option 1 or 2.
When i include the "And", it gives me the error "Type Mismatch"
I know its a syntax error.
Any help?
Thanks!
My code is below
'''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim Deliverable As String
Dim DateChanged As String
Dim VarItm As Variant
For Each VarItm In List2.ItemsSelected
Deliverable = Deliverable & "[ID] = " & List2.Column(0, VarItm) & " OR "
Next
If Deliverable <> "" Then
Deliverable = Left(Deliverable, Len(Deliverable) - 4)
Else
Deliverable = "True"
End If
If Me.txtFrom <> "" Then
DateChanged = "[DateChanged] Between #" & Format(Me.txtFrom, "m/d/yyyy") & _
"# And #" & Format(Me.txtTo + 1, "m/d/yyyy") & "#"
End If
DoCmd.OpenReport "rChangeReport", acViewReport, , Deliverable And DateChanged
I am having trouble filtering my report.
My goal is to filter the report by:
1) [DateChanged] by user entry on a form (txtFrom and txtTo)
2)[Deliverable] by selection of a list box on form
My error is in the last line when i open the report.
it only lets me filter using either option 1 or 2.
When i include the "And", it gives me the error "Type Mismatch"
I know its a syntax error.
Any help?
Thanks!
My code is below
'''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim Deliverable As String
Dim DateChanged As String
Dim VarItm As Variant
For Each VarItm In List2.ItemsSelected
Deliverable = Deliverable & "[ID] = " & List2.Column(0, VarItm) & " OR "
Next
If Deliverable <> "" Then
Deliverable = Left(Deliverable, Len(Deliverable) - 4)
Else
Deliverable = "True"
End If
If Me.txtFrom <> "" Then
DateChanged = "[DateChanged] Between #" & Format(Me.txtFrom, "m/d/yyyy") & _
"# And #" & Format(Me.txtTo + 1, "m/d/yyyy") & "#"
End If
DoCmd.OpenReport "rChangeReport", acViewReport, , Deliverable And DateChanged