JINKS
06-29-2000, 01:45 AM
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?
ingvar68
07-04-2000, 11:55 PM
it is difficult for access but decision is
see help PrtMip & PrtDevMode.
glad to answer
have a question? ask...
wiklendt
10-13-2008, 08:03 PM
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...
wiklendt
10-13-2008, 11:15 PM
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.modulesdao vba&tid=4f00a606-e220-47b0-b17a-32b737c18d16&cat=en_US_6ba00683-ae31-4f15-abe2-3bc70e8bebb1〈=en&cr=US&sloc=en-us&m=1&p=1 (http://www.microsoft.com/communities/newsgroups/en-us/default.aspx?dg=microsoft.public.access.modulesdao vba&tid=4f00a606-e220-47b0-b17a-32b737c18d16&cat=en_US_6ba00683-ae31-4f15-abe2-3bc70e8bebb1&lang=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:
Private Sub cmdPrintReport_Click()
'prints selected massage via pre-made report
On Error GoTo Err_cmdPreviewCurrentMassageReport_Click
Dim stDocName As String
Dim strCriteria As String
stDocName = "rptHorseMassage"
strCriteria = "[MassageID]= " & Me![MassageID]
'open report with given variables
DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenReport stDocName, acPreview, , strCriteria
'open the print dialog, then close report
DoCmd.RunCommand acCmdPrint
DoCmd.Close acReport, stDocName, acSaveNo
Exit_cmdPreviewCurrentMassageReport_Click:
Exit Sub
Err_cmdPreviewCurrentMassageReport_Click:
Select Case Err.Number
Case 2501
'command cancelled, close report
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!):
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
wiklendt
10-13-2008, 11:18 PM
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):
DoCmd.RunCommand acCmdPageSetup