title: Print Dialog in MS-Access
body: <p>I want to open a print dialog box. I haven't programmed in VB for a decade and I am more than a little rusty.</p>
  
  <p>I got a copy of an MS Access VB script that selects an MDB file and then prints only one copy. My thought process was:</p>
  
  <ol>
  <li>Open up a dialog box;</li>
  <li>Select the printer;</li>
  <li>Type in number of copies;</li>
  <li>Print.</li>
  </ol>
  
  <p>Currently, the portion of the original script I want to modify is:</p>
  
  <pre><code>[SQL query above this]
  ....
  
  ' Open form
  Dim rs As DAO.Recordset
  Set rs = db.OpenRecordset("select@@identity")
  Debug.Print rs(0)
  
  Dim q As String
  q = "transfer_id=" &amp; rs(0)
  DoCmd.OpenForm "Transfer Report", acNormal, , q, ,acDialog
  DoCmd.PrintOut
  
  ...
  [End If, End Sub, etc.]
  </code></pre>
  
  <p>This only prints out one instance of the report and the company does not have the ability to print out other copies at the same time. Since it is in the field, they don't have access to a copier but still need multiple copies.</p>
  
  <p>One answer I found, by David-W-Fenton (thank you!), shows how to create a dialog box; Would the following script accomplish what I want to do?  And, how do I add a portion to the dialog box to specify how many copies to print?</p>
  
  <pre><code>...  
  Dim varPrinter As Printer
  Dim strRowsource As String
  Dim q As String
  Dim rs As DAO.Recordset
  
  Set rs = db.OpenRecordset("select @@identity")
  Debug.Print rs(0)
  
  If Len(Me.OpenArgs) &gt; 0 Then
    q = Me.OpenArgs
    Me.Tag = q
    For Each varPrinter In Application.Printers
     strRowsource = strRowsource &amp; "; " &amp; varPrinter.DeviceName
    Next varPrinter
    Me!cmbPrinter.RowSource = Mid(strRowsource, 3)
    ' first check to see that the report is still open
  If (1 = SysCmd(acSysCmdGetObjectState, acReport, q)) Then
     With Reports(q).Printer
       Me!cmbPrinter = .DeviceName
       Me!optLayout = .Orientation
       End With
      Me!txtPageTo = Reports(q).Pages
    End If
  End If
  
  Public Function PrintReport(q As String) As Boolean
    q = "transfer_id=" &amp; rs(0)
   ' open report in PREVIEW mode but HIDDEN
   DoCmd.OpenReport q, acViewPreview, , , acHidden
   ' open the dialog form to let the user choose printing options
   DoCmd.OpenForm "dlgPrinter", , , , , acDialog, q
   With Forms!dlgPrinter
     If .Tag &lt;&gt; "Cancel" Then
      Set Reports(q).Printer = Application.Printers((!cmbPrinter))
      Reports(q).Printer.Orientation = !optLayout
      Application.Echo False
      DoCmd.SelectObject acReport, q
      DoCmd.PrintOut acPages, !txtPageFrom, !txtPageTo
      PrintReport = True
     End If
   End With
   DoCmd.Close acForm, "dlgPrinter"
   DoCmd.Close acReport, q
   Application.Echo True
  End Function
  </code></pre>