Floyd Sumner
asked on
Using dynamic variables in an Access 2010 SQL Query
What is the proper syntax for dynamic variables inside a MS Access 2010 SQL Select query?
Following is the code I'm trying to complete and I can't recall the correct syntax for placing dynamic variables inside a MS Access 2010 SQL Select query;
Dim STDate, EnDate As Date
Dim STtime, EnTime As Variant
Dim ProArea, SQLSearch As String
ProArea = Me.ProgArea
STDate = Me.StartDT
STime = Me.cmb_StartTime
EnDate = Me.EndDT
EnTime = Me.cmb_EndTime
SQLSearch = "SELECT VehiclePool.[Unit#], VehiclePool.[Year, Make, Model], VehiclePool.Program, VehiclePool.Location, tbl_VehicleSchedule.Purpos eOfTrip, " & _
"tbl_VehicleSchedule.Start DT, tbl_VehicleSchedule.EndDT INTO tbl_VehicleDatesResults " & _
"FROM VehiclePool INNER JOIN tbl_VehicleSchedule ON VehiclePool.[Unit#] = tbl_VehicleSchedule.[Unit# ] " & _
"WHERE (((VehiclePool.[Unit#]) Is Not Null) AND ((VehiclePool.Program)= ProArea) AND ((tbl_VehicleSchedule.Star tDT)=IsNul l((([tbl_V ehicleSche dule].[Sta rtDT]) " & _
"Between STDate And EnDate) Or ([tbl_VehicleSchedule].[St artDT])=Is Empty(([tb l_VehicleS chedule].[ StartDT]) Between STDate And EnDate)) Or " & _
"(tbl_VehicleSchedule.Star tDT) Is Null) AND ((tbl_VehicleSchedule.EndD T)=IsNull( (([tbl_Veh icleSchedu le].[EndDT ]) Between STDate And EnDate) Or " & _
"([tbl_VehicleSchedule].[E ndDT])=IsE mpty(([tbl _VehicleSc hedule].[E ndDT]) Between STDate And EnDate)) Or (tbl_VehicleSchedule.EndDT ) Is Null));"
Following is the code I'm trying to complete and I can't recall the correct syntax for placing dynamic variables inside a MS Access 2010 SQL Select query;
Dim STDate, EnDate As Date
Dim STtime, EnTime As Variant
Dim ProArea, SQLSearch As String
ProArea = Me.ProgArea
STDate = Me.StartDT
STime = Me.cmb_StartTime
EnDate = Me.EndDT
EnTime = Me.cmb_EndTime
SQLSearch = "SELECT VehiclePool.[Unit#], VehiclePool.[Year, Make, Model], VehiclePool.Program, VehiclePool.Location, tbl_VehicleSchedule.Purpos
"tbl_VehicleSchedule.Start
"FROM VehiclePool INNER JOIN tbl_VehicleSchedule ON VehiclePool.[Unit#] = tbl_VehicleSchedule.[Unit#
"WHERE (((VehiclePool.[Unit#]) Is Not Null) AND ((VehiclePool.Program)= ProArea) AND ((tbl_VehicleSchedule.Star
"Between STDate And EnDate) Or ([tbl_VehicleSchedule].[St
"(tbl_VehicleSchedule.Star
"([tbl_VehicleSchedule].[E
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
@ste5an,
<<Dim STDate, EnDate As Date>>
Good catch!
Jim.
<<Dim STDate, EnDate As Date>>
Good catch!
Jim.
ASKER