PAGE SETUP

JINKS

New member
Local time
Today, 07:37
Joined
Feb 3, 2000
Messages
7
I Want to change the page setup for a form using VB code, to the following:
Margins: Top 5mm, Bottom 5mm, Left 5mm, Right 5mmm.
Orientation: Landscape
Paper size: A3
Anyone got any ides?
 
it is difficult for access but decision is

see help PrtMip & PrtDevMode.

glad to answer
have a question? ask...
 
hey, i've been looking around the web to see if there is an easier way (seeing as 8 whole years have passed since the last post on this thread) to open the common print dialogue via a button on a form to print a given report....? i've not been successful, but maybe someone else out there knows of a way?

i've read PrtMip is a) no longer supported by MS; and b) cannot be used in mde files.

while i don't have an mde file, i don't know whether in the future i may want to convert it to one, so i'd like and easy way to go about this...
 
ok, i'm going to answer my own question: hope that's ok with everyone.

i found this site: http://www.microsoft.com/communities/newsgroups/en-us/default.aspx?dg=microsoft.public.access.modulesdaovba&tid=4f00a606-e220-47b0-b17a-32b737c18d16&cat=en_US_6ba00683-ae31-4f15-abe2-3bc70e8bebb1〈=en&cr=US&sloc=en-us&m=1&p=1

and managed to get it to do what i want buy adding supporting code, although i would prefer not to have to open the report, this is fine for my purposes. here is my full subroutine; via a button on my form, it opens a report and the print dialogue, then when the user selects either to print or to cancel, VBA closes the report and heads back to the original form:

Code:
Private Sub cmdPrintReport_Click()
[COLOR=SeaGreen]'prints selected massage via pre-made report
[/COLOR] 
On Error GoTo Err_cmdPreviewCurrentMassageReport_Click

    Dim stDocName As String
    Dim strCriteria As String

    stDocName = "rptHorseMassage"
    strCriteria = "[MassageID]= " & Me![MassageID]
    [COLOR=SeaGreen]
    'open report with given variables[/COLOR]
    DoCmd.RunCommand acCmdSaveRecord
    DoCmd.OpenReport stDocName, acPreview, , strCriteria

    [COLOR=SeaGreen]'open the print dialog, then close report[/COLOR]
    DoCmd.RunCommand acCmdPrint
    DoCmd.Close acReport, stDocName, acSaveNo

Exit_cmdPreviewCurrentMassageReport_Click:
    Exit Sub

Err_cmdPreviewCurrentMassageReport_Click:
    Select Case Err.Number
      Case 2501
[COLOR=SeaGreen]        'command cancelled, close report[/COLOR]
        DoCmd.Close acReport, stDocName, acSaveNo
      Case Else
        MsgBox Err.Description
    End Select
    Resume Exit_cmdPreviewCurrentMassageReport_Click

End Sub
i know boB would cringe at my "select case" way of handling the error number, but i have found that some of my subroutines produce more than one 'error', which MAY need to be handled differently, so i have chosen to do it this way "just in case"... for those intersted, boB's prefered handling would look like this (correct me if i'm wrong, boB!):

Code:
Err_cmdPreviewCurrentMassageReport_Click:
   If Err.Number <> 2501
        Msg = "Error # " & Str(Err.Number) & Chr(13) & Err.Description
        MsgBox Msg, , "Error", Err.HelpFile, Err.HelpContext
    End If
Resume Exit_cmdPreviewCurrentMassageReport_Click

End Sub
 
sorry, i don't think my posts help JINKS, though... *blush*

edit: HOWEVER, the link provided does also give this code, which may help JINKS (or others trying to do the same thing):

Code:
[FONT=Verdana, Arial, Helvetica][SIZE=2]DoCmd.RunCommand acCmdPageSetup
[/SIZE][/FONT]
 
Last edited:

Users who are viewing this thread

Back
Top Bottom