DebbieCoates
Programmer
I am looking at a database that is in use the the company I work for.
on every from in the database is a print button, and behind it the code
On Error GoTo failure
Select Case Printer.Orientation
Case Is = vbPRORLandscape
Me.PrintForm
Printer.EndDoc
Case Is = vbPRORPortrait
Printer.Orientation = vbPRORLandscape
Me.PrintForm
Printer.Orientation = vbPRORPortrait
Printer.EndDoc
Case Else
GoTo failure
End Select
Exit Sub
failure:
MsgBox "Unable to determine printer orientation", vbCritical
I was wondering, rather than have this code on everyform, is it possible call a function or subroutine, and send the form name to that function/subroutine where it says Me.PrintForm
I tried this but get an error
Public Sub pr_Form(strFormName As String)
Dim frm As Form
Set frm = strFormName
On Error GoTo failure
Select Case Printer.Orientation
Case Is = vbPRORLandscape
frm.PrintForm
Printer.EndDoc
Case Is = vbPRORPortrait
Printer.Orientation = vbPRORLandscape
frm.PrintForm
Printer.Orientation = vbPRORPortrait
Printer.EndDoc
Case Else
GoTo failure
End Select
Exit Sub
failure:
MsgBox "Unable to determine printer orientation", vbCritical
End Sub
on every from in the database is a print button, and behind it the code
On Error GoTo failure
Select Case Printer.Orientation
Case Is = vbPRORLandscape
Me.PrintForm
Printer.EndDoc
Case Is = vbPRORPortrait
Printer.Orientation = vbPRORLandscape
Me.PrintForm
Printer.Orientation = vbPRORPortrait
Printer.EndDoc
Case Else
GoTo failure
End Select
Exit Sub
failure:
MsgBox "Unable to determine printer orientation", vbCritical
I was wondering, rather than have this code on everyform, is it possible call a function or subroutine, and send the form name to that function/subroutine where it says Me.PrintForm
I tried this but get an error
Public Sub pr_Form(strFormName As String)
Dim frm As Form
Set frm = strFormName
On Error GoTo failure
Select Case Printer.Orientation
Case Is = vbPRORLandscape
frm.PrintForm
Printer.EndDoc
Case Is = vbPRORPortrait
Printer.Orientation = vbPRORLandscape
frm.PrintForm
Printer.Orientation = vbPRORPortrait
Printer.EndDoc
Case Else
GoTo failure
End Select
Exit Sub
failure:
MsgBox "Unable to determine printer orientation", vbCritical
End Sub