my first post…..
The scenario:
- I have a print function that opens a report and opens it in a new window for print preview using acdialog (the customer specifically doesn't want the acViewPreview, , , acHidden as that opens it in the Access Window)
- based on the orientation (portrait or landscape) the duplex setting of the printer needs to be set correctly
The following works well BUT only in an .accdb and I want to lock the app for users into an .accde.
In the .accde the following error occurs: "the command you specified is not available in an .mde, .accde or .ade database" which must be because of the acViewDesign option. I don't know another way though to inquire the orientation of the report without opening it and I would not like to open it twice visibly for the user (once to get the orientation and secondly for the print preview in a separate window.
Any ideas how I can achieve this?
Function PrintDoc(DocName As String)
On Error GoTo Err_PrintDoc
DoCmd.OpenReport DocName, acViewDesign, , , acHidden
If Reports(DocName).Printer.Orientation = acPRORLandscape Then
Reports(DocName).Printer.Duplex = acPRDPVertical
Else
Reports(DocName).Printer.Duplex = acPRDPHorizontal
End If
DoCmd.Close acReport, DocName, acSaveYes
DoCmd.OpenReport DocName, acViewPreview, , , acDialog
Exit_PrintDoc:
Exit Function
Err_PrintDoc:
MsgBox Err.Description
Resume Exit_PrintDoc:
End Function
The scenario:
- I have a print function that opens a report and opens it in a new window for print preview using acdialog (the customer specifically doesn't want the acViewPreview, , , acHidden as that opens it in the Access Window)
- based on the orientation (portrait or landscape) the duplex setting of the printer needs to be set correctly
The following works well BUT only in an .accdb and I want to lock the app for users into an .accde.
In the .accde the following error occurs: "the command you specified is not available in an .mde, .accde or .ade database" which must be because of the acViewDesign option. I don't know another way though to inquire the orientation of the report without opening it and I would not like to open it twice visibly for the user (once to get the orientation and secondly for the print preview in a separate window.
Any ideas how I can achieve this?
Function PrintDoc(DocName As String)
On Error GoTo Err_PrintDoc
DoCmd.OpenReport DocName, acViewDesign, , , acHidden
If Reports(DocName).Printer.Orientation = acPRORLandscape Then
Reports(DocName).Printer.Duplex = acPRDPVertical
Else
Reports(DocName).Printer.Duplex = acPRDPHorizontal
End If
DoCmd.Close acReport, DocName, acSaveYes
DoCmd.OpenReport DocName, acViewPreview, , , acDialog
Exit_PrintDoc:
Exit Function
Err_PrintDoc:
MsgBox Err.Description
Resume Exit_PrintDoc:
End Function