hello,
i am trying to pass the where value with a variable, so it should be dynamic, can someone help me with that as so far i ma not successful, syntax below,
any help is appreciated
i am trying to pass the where value with a variable, so it should be dynamic, can someone help me with that as so far i ma not successful, syntax below,
any help is appreciated
Code:
Private Function tsSql(strTripStatus As Integer, TripField As String, Optional dtOccupeidDate As Date, Optional intDispatchID As Integer) As String
Dim varWhere
varWhere = "" & TripField & " between #" & FromDate & "# and #" & ToDate & "#"
"INSERT INTO tmpDispatch ( TripDate, TripTime, GroupName, Action, DEST, Address, Near, CSZ, ReturnDate, ReturnTime, ContactPerson, PhoneDay, Driver, Bus, Collect, ContractId, Comments, [Dispatch ID],[PO#],InCharge,sReturn,sPickUp, ContractDetailID, sLeaveGarage,TripStatus,OccupeidDate) " _
& "SELECT ContractDetails.TripDate, ContractDetails.TripTime, Customers.GroupName, ContractStops.Action, Destination.DEST, Destination.Address, Destination.Near, [Destination]![Town] & ', ' & [Destination]![state] & ' ' & [Destination]![zip] AS CSZ, " _
& "ContractDetails.ReturnDate, ContractDetails.ReturnTime, Contracts.ContactPerson, Customers.PhoneDay, Dispatch.Driver, Dispatch.Bus, Dispatch.Collect, Contracts.ContractId, Dispatch.Comments, Val([DispatchID]) AS [Dispatch ID],[PO#],InCharge,sReturn,sPickUp, ContractDetails.ContractDetailID, Dispatch.sLeaveGarage," & strTripStatus & " ,#" & dtOccupeidDate & "#" _
& "FROM (Customers INNER JOIN Contracts ON Customers.CustomerId = Contracts.CustomerId) " _
& "INNER JOIN ((Dispatch INNER JOIN ContractDetails ON Dispatch.ContractDetailID = ContractDetails.ContractDetailID) INNER JOIN (Destination INNER JOIN ContractStops ON Destination.PlaceID = ContractStops.PlaceID) ON ContractDetails.ContractDetailID = ContractStops.ContractDetailID) ON Contracts.ContractId = ContractDetails.ContractID " _
[COLOR="Red"] & " Where '" & varWhere & "';"[/COLOR]