Try this less involved version :
- Dim LDT1 As Date
-
Dim LTD2 As Date
-
Dim strWhere As String
-
Dim strDate1 As String
-
Dim strDate2 As String
-
-
LDT1 = frmGroundOperationsSelectReport.DTPicker1.Value
-
LDT2 = frmGroundOperationsSelectReport.DTPicker2.Value
-
-
If CStr(LDT1) = "" Or CStr(LDT2) = "" Then Exit Sub
-
-
Set appaccess = CreateObject("Access.Application")
-
-
dbstr = "C:\Scheduling\AAGTC_Scheduling.mdb"
-
-
appaccess.OpenCurrentDatabase dbstr
-
-
strDate1 = Format(LDT1, "\#m/d/yyyy\#")
-
strDate2 = Format(LDT2, "\#m/d/yyyy\#")
-
strWhere = "(([Date_In] <= " & strDate2 & ") And (" & [Date_Out] >= " & strDate1 & "))"
-
-
appaccess.DoCmd.OpenReport "DailyGroundScheduleReport", acViewPreview, vbMaximized, strWhere
-
-
appaccess.Visible = True
In VBA (I'm assuming in VB too) you can't use named parameters unless all are named.
ALL date literals in SQL MUST be in d/m/y format (which isn't the default in all locations).
The logic is that one StartDate must be less than or equal to the other EndDate AS WELL AS the EndDate (of the first StartDate) must be greater than or equal to the other StartDate.