Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

always print form = landscape

0 views
Skip to first unread message

Dianne Dalton

unread,
Sep 1, 2002, 10:16:49 PM9/1/02
to
hey all

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: __________________________________________________________________


Michael Painter

unread,
Sep 1, 2002, 10:41:14 PM9/1/02
to

"Dianne Dalton" <dianne...@tvnz.co.nz> wrote in message
news:OSzc9.7128$CD2.9...@news02.tsnz.net...

> hey all
>
> 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
There are ways to control the printer, more in XP than before but this
should not be necessary.
Just set up the printer for that report and save it. It will be saved with
the report.
HOWEVER. If you reopen the report in design view it may get changed back. I
don't know why and it is not consistent.
I've never seen it happen while actually using the reports.


Dianne Dalton

unread,
Sep 2, 2002, 12:03:31 AM9/2/02
to
Thanks but yes that was the problem, as I do need to change the design in
this one sometimes, I just need to add the Orientation but I'm not sure of
the exact coding

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...

Remi Despres

unread,
Sep 2, 2002, 9:08:17 AM9/2/02
to
Hi Dianne.
Here's some code from a module of mine I use to modify reports
on-the-fly. This must be run with the report in design mode,
unfortunately, and then needs to be saved. However, the change happens
so quickly it results in just a flash on the screen. Set echo or
Painting to false if you don't want to see it. Also, I've found that
if you change the settings for a report on one machine and then move
your application to a different machine, the settings will have been
reset on the new machine. (An annoyance, if nothing else.)

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>...

Remi Despres

unread,
Sep 2, 2002, 10:07:34 AM9/2/02
to
Oops, I thought you were trying to print a report, not a form. My
other post won't work for a form.

R/mi.


"Dianne Dalton" <dianne...@tvnz.co.nz> wrote in message news:<SqBc9.7142$CD2.9...@news02.tsnz.net>...

0 new messages