[RESOLVED] About Printer...
hello folks, I have a problem,
I want to make a sub that changes the form and number of copies of the printer for the next print job, like:
Private Sub SetPrinterForm(formName As String, copies As Long)
I did the following code with no effects, I don't find where is the error,
please, if you know where is it, please tell me,
thanks a lot, Angel.
Code:
Private Sub SetPrinterForm(formName As String, copies As Long)
Dim hPrinter As Long
Dim cbRequired As Long
Dim pd As PRINTER_DEFAULTS
Dim pi2 As PRINTER_INFO_2
Dim buff() As Long
Dim dm As DEVMODE
pd.DesiredAccess = PRINTER_ACCESS_USE Or PRINTER_ACCESS_ADMINISTER
If (OpenPrinter(VB.Printer.DeviceName, hPrinter, pd) <> 0) Then
If (GetPrinter(hPrinter, 2, 0&, 0&, cbRequired) = 0) Then
ReDim buff(cbRequired) As Long
If GetPrinter(hPrinter, 2, buff(0), cbRequired, cbRequired) <> 0 Then
Call CopyMemory(pi2, buff(0), Len(pi2))
dm = pi2.pDevMode
dm.dmFields = 0
dm.dmFields = DM_FORMNAME Or DM_COPIES
dm.dmFormName = formName & Chr(0)
dm.dmCopies = copies
pi2.pDevMode = dm
Call SetPrinter(hPrinter, 2, pi2, 0&)
End If
End If
Call ClosePrinter(hPrinter)
End If
End Sub
Re: [RESOLVED] About Printer...
Angel,
Good afternoon.
Can this code be tweaked so that it can assist MS Access in detecting whether an Access report has been sent to the printer?
My objective is to trigger some code when my report has been sent to the printer and not to the screen.
My code is in the "PageHeaderSection" of the report under the OnPrint event.
It works fine but I only need it to execute one time and that is when the user actually sends the report to the printer (i.e. File -> Print). I know that the Print dialog can be open using the Docmd object but it does not expose any of the Print dialog's methods or properties.
Is there any way to adjust this code to assist MS Access in detecting whether the Print dialog is open?
Thanks,
BigJohnT