Can someone show me the line I would put in my code to do the above - I
already have a procedure on the form so hopefully can just add into the
same.
cheers
Dianne
__________________________________________________________________ Dianne D
ICQ#: 13567847 Current ICQ status: + More ways to contact me i See more
about me: __________________________________________________________________
This is my code so far: but I'm sure I have seen where you can add the
orientation in as a line
Private Sub printform_Click()
On Error GoTo Err_printform_Click
Dim stDocName As String
Dim MyForm As Form
stDocName = "subform_avalon"
Set MyForm = Screen.ActiveForm
DoCmd.SelectObject acForm, stDocName, True
DoCmd.PrintOut
DoCmd.SelectObject acForm, MyForm.Name, False
Exit_printform_Click:
Exit Sub
Err_printform_Click:
MsgBox Err.Description
Resume Exit_printform_Click
End Sub
thanks
"Michael Painter" <m.pa...@worldnet.att.net> wrote in message
news:edAc9.5948$jG2.4...@bgtnsc05-news.ops.worldnet.att.net...
I noted in my code comments that the function should only be called
while in design mode. If memory serves (I wrote this a while ago), I
believe an error will be thrown if you try to call this in an mde.
This because the report must be opened in design mode and that isn't
allowed in mde files.
Hope this helps.
Best regards,
R/mi.
* * *
Public Enum PrintOrientation
DM_PORTRAIT = 1
DM_LANDSCAPE = 2
End Enum
Private Type str_DEVMODE
RGB As String * 94
End Type
Private Type type_DEVMODE
strDeviceName As String * 16
intSpecVersion As Integer
intDriverVersion As Integer
intSize As Integer
intDriverExtra As Integer
lngFields As Long
intOrientation As Integer
intPaperSize As Integer
intPaperLength As Integer
intPaperWidth As Integer
intScale As Integer
intCopies As Integer
intDefaultSource As Integer
intPrintQuality As Integer
intColor As Integer
intDuplex As Integer
intResolution As Integer
intTTOption As Integer
intCollate As Integer
strFormName As String * 16
lngPad As Long
lngBits As Long
lngPW As Long
lngPH As Long
lngDFI As Long
lngDFr As Long
End Type
'lngFields constants, used to indicate which DEVMODE
'structure fields have been initialized...
Private Const DM_ORIENTATION As Long = &H1
Private Const DM_PAPERSIZE As Long = &H2
Private Const DM_PAPERLENGTH As Long = &H4
Private Const DM_PAPERWIDTH As Long = &H8
Private Const DM_SCALE As Long = &H10
Private Const DM_COPIES As Long = &H100
Private Const DM_DEFAULTSOURCE As Long = &H200
Private Const DM_PRINTQUALITY As Long = &H400
Private Const DM_COLOR As Long = &H800
Private Const DM_DUPLEX As Long = &H1000
Private Const DM_YRESOLUTION As Long = &H2000
Private Const DM_TTOPTION As Long = &H4000
' Function setReportPrintOrientation
'
' This function will set the printing orientation (portrait or
' landscape) for any given report, passed by parameter, identified
' by name.
'
' The function opens the report in design view - this is required.
' The PrtDevMode property can only be assigned to in design mode. This
' function should only be called in design mode as well.
'
' Inputs: String, a report name. PrintOrientation, an orientation.
' Outputs: None.
' Side Effects: The report's print orientation will be set to either
' landscape or portrait, depending on the parameter.
Public Function setReportPrintOrientation( _
ByVal strReportName As String, _
ByVal dmOrient As PrintOrientation)
Dim rpt As Report
' Opens report in Design view.
DoCmd.OpenReport strReportName, acDesign
Set rpt = Reports(strReportName)
If Not IsNull(rpt.PrtDevMode) Then _
rpt.PrtDevMode = changePrintDefault(rpt.PrtDevMode, _
DM_ORIENTATION, dmOrient)
End Function
' Function changePrintDefault
'
' This function will change a print default for a
' report (which must already be opened in design mode).
' Any function that changes a default print value should
' call this one to do the actual work.
'
' This function may be called consecutive times for the
' same report, to change a number of different fields.
'
' Inputs:
' strDevModeExtra - the report's PrtDevMode attribute;
' lngField - one of the DM_* constants, which indicate the
' field that's being modified;
' lngValue - the field's new value.
'
' Outputs: String, the new, modified PrtDevMode attribute to be used.
' Side Effects: Updates the report's setting.
Private Function changePrintDefault( _
ByVal strDevModeExtra As String, _
ByVal lngField As Long, _
ByVal lngValue As Long) As String
Dim DevString As str_DEVMODE
Dim DM As type_DEVMODE
Const ERROR_NOT_IMPLEMENTED As String = "This setting can't be
modified - it hasn't been implemented yet."
DevString.RGB = strDevModeExtra
LSet DM = DevString
'Set fields so that the structure is aware
'that a (or another) field has been initialized...
DM.lngFields = DM.lngFields Or lngField
'What specific field is being updated this time? Update it.
Select Case lngField
Case DM_ORIENTATION
DM.intOrientation = lngValue
Case DM_PAPERSIZE
DM.intPaperSize = lngValue
'The rest aren't needed. I put them here for
'completeness' sake (these are all the fields
'we could actually modify if we wanted to), and
'it won't take much work to implement.
Case DM_PAPERLENGTH
MsgBox ERROR_NOT_IMPLEMENTED, vbExclamation Or
vbApplicationModal Or vbOKOnly, "Nice Try"
Case DM_PAPERWIDTH
MsgBox ERROR_NOT_IMPLEMENTED, vbExclamation Or
vbApplicationModal Or vbOKOnly, "Nice Try"
Case DM_SCALE
MsgBox ERROR_NOT_IMPLEMENTED, vbExclamation Or
vbApplicationModal Or vbOKOnly, "Nice Try"
Case DM_COPIES
MsgBox ERROR_NOT_IMPLEMENTED, vbExclamation Or
vbApplicationModal Or vbOKOnly, "Nice Try"
Case DM_DEFAULTSOURCE
MsgBox ERROR_NOT_IMPLEMENTED, vbExclamation Or
vbApplicationModal Or vbOKOnly, "Nice Try"
Case DM_PRINTQUALITY
MsgBox ERROR_NOT_IMPLEMENTED, vbExclamation Or
vbApplicationModal Or vbOKOnly, "Nice Try"
Case DM_COLOR
MsgBox ERROR_NOT_IMPLEMENTED, vbExclamation Or
vbApplicationModal Or vbOKOnly, "Nice Try"
Case DM_DUPLEX
MsgBox ERROR_NOT_IMPLEMENTED, vbExclamation Or
vbApplicationModal Or vbOKOnly, "Nice Try"
Case DM_YRESOLUTION
MsgBox ERROR_NOT_IMPLEMENTED, vbExclamation Or
vbApplicationModal Or vbOKOnly, "Nice Try"
Case DM_TTOPTION
MsgBox ERROR_NOT_IMPLEMENTED, vbExclamation Or
vbApplicationModal Or vbOKOnly, "Nice Try"
End Select
'Finishing touches, to return the PrtDevMode string
LSet DevString = DM
Mid(strDevModeExtra, 1, 94) = DevString.RGB
changePrintDefault = strDevModeExtra
End Function
"Dianne Dalton" <dianne...@tvnz.co.nz> wrote in message news:<SqBc9.7142$CD2.9...@news02.tsnz.net>...
R/mi.
"Dianne Dalton" <dianne...@tvnz.co.nz> wrote in message news:<SqBc9.7142$CD2.9...@news02.tsnz.net>...