Hello All,
I have a cascading drop down box with 4 fields which works wonderfully to produce individual reports based on a querydef written in VBA. Everything works great, I can bring up all 675 variations of the product with respective costs to produce each one.
It would take a couple of days to select and print each one individually.
So what I need to do is have a method to print them all (each variation) without having to select each one using the cascading form.
Naturally I won't want 675 reports hitting the printer at once so I could break it up into size or color or style, etc.
Any suggestions? I understand that a macro or VBA is in order, but where do I start? Here is my vba that works so well already...
Private Sub cmdRunMirDoorsQry_Click()
On Error GoTo cmdOK_Click_err
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim strSQL As String
Set db = CurrentDb
Set qdf = db.QueryDefs("qryMirDoors")
'Here is the select statement
strSQL = "SELECT tblMirDoors.* " & _
"FROM tblMirDoors " & _
"WHERE tblMirDoors.strMirDrSeriesID='" & Me.cboSeries.Value & "' " & _
"AND tblMirDoors.strMirDrSizID='" & Me.cboSizes.Value & "' " & _
"AND tblMirDoors.strMirDrColrID='" & Me.cboFrColr.Value & "' " & _
"AND tblMirDoors.strMirDrPanelID='" & Me.cboPanels.Value & "' " & _
"ORDER BY tblMirDoors.strMirDrSeriesID;"
DoCmd.Echo False
If Application.SysCmd(acSysCmdGetObjectState, acQuery, "qryMirDoors") = acObjStateOpen Then
DoCmd.Close acQuery, "qryMirDoors"
End If
qdf.SQL = strSQL
DoCmd.OpenReport "rptMirDoors", acViewPreview
DoCmd.Echo True
'qdf.SQL = strSQL
'DoCmd.OpenQuery "qryMirDrSelect"
cmdOK_Click_exit:
DoCmd.Echo True
Set qdf = Nothing
Set db = Nothing
Exit Sub
cmdOK_Click_err:
MsgBox "There is no such Mirror Door for the selection you made." & _
vbCrLf & "The software allowed an incorrect choice, sorry." & _
vbCrLf & "Please hit RESET and try again!" & _
vbCrLf & _
vbCrLf & "Error Number: " & Err.Number & _
vbCrLf & "Description: " & Err.Description _
, vbCritical, "Error"
Resume cmdOK_Click_exit
End Sub
Thanks for any help you can suggest...
I have a cascading drop down box with 4 fields which works wonderfully to produce individual reports based on a querydef written in VBA. Everything works great, I can bring up all 675 variations of the product with respective costs to produce each one.
It would take a couple of days to select and print each one individually.
So what I need to do is have a method to print them all (each variation) without having to select each one using the cascading form.
Naturally I won't want 675 reports hitting the printer at once so I could break it up into size or color or style, etc.
Any suggestions? I understand that a macro or VBA is in order, but where do I start? Here is my vba that works so well already...
Private Sub cmdRunMirDoorsQry_Click()
On Error GoTo cmdOK_Click_err
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim strSQL As String
Set db = CurrentDb
Set qdf = db.QueryDefs("qryMirDoors")
'Here is the select statement
strSQL = "SELECT tblMirDoors.* " & _
"FROM tblMirDoors " & _
"WHERE tblMirDoors.strMirDrSeriesID='" & Me.cboSeries.Value & "' " & _
"AND tblMirDoors.strMirDrSizID='" & Me.cboSizes.Value & "' " & _
"AND tblMirDoors.strMirDrColrID='" & Me.cboFrColr.Value & "' " & _
"AND tblMirDoors.strMirDrPanelID='" & Me.cboPanels.Value & "' " & _
"ORDER BY tblMirDoors.strMirDrSeriesID;"
DoCmd.Echo False
If Application.SysCmd(acSysCmdGetObjectState, acQuery, "qryMirDoors") = acObjStateOpen Then
DoCmd.Close acQuery, "qryMirDoors"
End If
qdf.SQL = strSQL
DoCmd.OpenReport "rptMirDoors", acViewPreview
DoCmd.Echo True
'qdf.SQL = strSQL
'DoCmd.OpenQuery "qryMirDrSelect"
cmdOK_Click_exit:
DoCmd.Echo True
Set qdf = Nothing
Set db = Nothing
Exit Sub
cmdOK_Click_err:
MsgBox "There is no such Mirror Door for the selection you made." & _
vbCrLf & "The software allowed an incorrect choice, sorry." & _
vbCrLf & "Please hit RESET and try again!" & _
vbCrLf & _
vbCrLf & "Error Number: " & Err.Number & _
vbCrLf & "Description: " & Err.Description _
, vbCritical, "Error"
Resume cmdOK_Click_exit
End Sub
Thanks for any help you can suggest...