P
Paul B.
I have since found that I cannot use the dd/mm/yyyy date format, so I am now
wondering if I can use an SQL statement to apply criteria to open a form to
specific records.
I need to replace the following code with an SQL statement if possible
----------------------------------------------------
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmDispositionHistory"
If IsNull([txtStartDate]) And IsNull([txtEndDate]) Then
stLinkCriteria = "[VehicleNumber]=" & Me![VehicleNumber]
Else
stLinkCriteria = "VehicleNumber='" & Me!VehicleNumber & "' And " &
"DispositionDate BETWEEN #" & Format$(Me!txtStartDate, "dd/mm/yyyy") & "#
AND # " & Format$(Me!txtEndDate, "dd/mm/yyyy") & "#"
End If
DoCmd.OpenForm stDocName, , , stLinkCriteria
-----------------------------------------------------------------------
Here is the value of stLinkCriteria:
stLinkCriteria = "VehicleNumber='4091' AND DispositionDate BETWEEN
#01/12/2004# AND #04/01/2005#"
When the DoCmd.OpenForm part runs, this causes an error that states
OpenForm action was cancelled. I am assuming that it has something to do with
the date format, because without selecting dates, the form opens just fine.
If there is some other way of doing this, I would appreciate a nudge in that
direction.
Cheers
wondering if I can use an SQL statement to apply criteria to open a form to
specific records.
I need to replace the following code with an SQL statement if possible
----------------------------------------------------
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmDispositionHistory"
If IsNull([txtStartDate]) And IsNull([txtEndDate]) Then
stLinkCriteria = "[VehicleNumber]=" & Me![VehicleNumber]
Else
stLinkCriteria = "VehicleNumber='" & Me!VehicleNumber & "' And " &
"DispositionDate BETWEEN #" & Format$(Me!txtStartDate, "dd/mm/yyyy") & "#
AND # " & Format$(Me!txtEndDate, "dd/mm/yyyy") & "#"
End If
DoCmd.OpenForm stDocName, , , stLinkCriteria
-----------------------------------------------------------------------
Here is the value of stLinkCriteria:
stLinkCriteria = "VehicleNumber='4091' AND DispositionDate BETWEEN
#01/12/2004# AND #04/01/2005#"
When the DoCmd.OpenForm part runs, this causes an error that states
OpenForm action was cancelled. I am assuming that it has something to do with
the date format, because without selecting dates, the form opens just fine.
If there is some other way of doing this, I would appreciate a nudge in that
direction.
Cheers