N
NoodNutt
Hi all
I am fairly comfortably around standard nested queries, but I get in a world
of hurt when it comes to QueryDef's.
Can anyone assist with structuring the following please.
Private Sub CmdBtnNSW_Click()
Dim dbMyDB As Database, NSWQuery As QueryDef
Dim rsMyRS As Recordset, strMySQL As String
Dim myDateOut As Date
strmysql = "PARAMETERS DateOut date;" & _
"SELECT tblPupDetails.DateOut, tblPupDetails.DestState,
tblCustomers.CustName, tblPupDetails.QTY, tblType.TypeDesc,
tblPupDetails.Weight, tblDrivers.DriverName" & _
" FROM tblDrivers RIGHT JOIN (tblType RIGHT JOIN (tblPupDetails
INNER JOIN tblCustomers ON tblPupDetails.CustID = tblCustomers.CustID) ON
tblType.TypeID = tblPupDetails.Type) ON tblDrivers.DriverID =
tblPupDetails.DriverAllocated" & _
" WHERE (tblPupDetails.DateOut =[DateOut] AND
(tblPupDetails.DestState ="NSW"));"
Set dbMyDB = CurrentDb
Set NSWQuery = dbMyDB.CreateQueryDef("NSW Report", strMySQL)
NSWQuery.Parameters("DateOut") = Forms!frmLinehaul!SendDate
Set rsMyRS = NSWQuery.OpenRecordset()
rsMyRS.Close
dbMyDB.Close
End Sub
What I would like to happen is that in the linehaul form the user can select
indivual states to view a report indicating volumes for the particular day.
The initial parameter will match up with the date displayed on the Linehaul
form, the second parameter would filter out all DestStates that = "NSW".
Finally, I need to be able to access this generated QDef to display in a
report.
Any assistance is appreciated
TIA
Mark.
I am fairly comfortably around standard nested queries, but I get in a world
of hurt when it comes to QueryDef's.
Can anyone assist with structuring the following please.
Private Sub CmdBtnNSW_Click()
Dim dbMyDB As Database, NSWQuery As QueryDef
Dim rsMyRS As Recordset, strMySQL As String
Dim myDateOut As Date
strmysql = "PARAMETERS DateOut date;" & _
"SELECT tblPupDetails.DateOut, tblPupDetails.DestState,
tblCustomers.CustName, tblPupDetails.QTY, tblType.TypeDesc,
tblPupDetails.Weight, tblDrivers.DriverName" & _
" FROM tblDrivers RIGHT JOIN (tblType RIGHT JOIN (tblPupDetails
INNER JOIN tblCustomers ON tblPupDetails.CustID = tblCustomers.CustID) ON
tblType.TypeID = tblPupDetails.Type) ON tblDrivers.DriverID =
tblPupDetails.DriverAllocated" & _
" WHERE (tblPupDetails.DateOut =[DateOut] AND
(tblPupDetails.DestState ="NSW"));"
Set dbMyDB = CurrentDb
Set NSWQuery = dbMyDB.CreateQueryDef("NSW Report", strMySQL)
NSWQuery.Parameters("DateOut") = Forms!frmLinehaul!SendDate
Set rsMyRS = NSWQuery.OpenRecordset()
rsMyRS.Close
dbMyDB.Close
End Sub
What I would like to happen is that in the linehaul form the user can select
indivual states to view a report indicating volumes for the particular day.
The initial parameter will match up with the date displayed on the Linehaul
form, the second parameter would filter out all DestStates that = "NSW".
Finally, I need to be able to access this generated QDef to display in a
report.
Any assistance is appreciated
TIA
Mark.