If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Setting Print Margins
Access seems to reset the print margins at random.
I am looking for a way to set the margins when a form is opened. I assume that I need an On Open Event Proceedure and have written some code based on the stuff contained in the Access Help file but it refuses to run and gives the following error message. The expression On Open you entered as the event property setting produced the following error: Cannot define a public user-defined type within an object Module. * The expression may no result in the name of a macro, the name of a user-defined function, or [Event Proceedure]. * There may have been an error evaluation the function, event, or macro. Can some one help me out please? Code follows ================================================== ======= Option Compare Database Option Explicit Type str_PRTMIP strRGB As String * 28 End Type Type type_PRTMIP xLeftMargin As Long yTopMargin As Long xRightMargin As Long yBotMargin As Long End Type Private Sub Form_Open(Cancel As Integer) SetMarginsToDefault "F001 Carriageway Records" 'Name of the form End Sub Public Sub SetMarginsToDefault(strName As String) Dim PrtMipString As str_PRTMIP Dim PM As type_PRTMIP Dim rpt As Report DoCmd.OpenForm strName, acDesign Set rpt = Forms(strName) PrtMipString.strRGB = rpt.PrtMip LSet PM = PrtMipString PM.intLeftMargin = 0.3937 * 1440 ' Set margins. This gives 10mmm I think PM.intTopMargin = 0.3937 * 1440 PM.intRightMargin = 0.3937 * 1440 PM.intBotMargin = 0.3937 * 1440 LSet PrtMipString = PM ' Update property. rpt.PrtMip = PrtMipString.strRGB ' probably not needed if this runs every time the form is opened 'DoCmd.Close acForm, strName, acSaveYes End Sub ================================================== ========== |
#2
|
|||
|
|||
Setting Print Margins
The problem of reports that do not hold their margins can be traced to Name
AutoCorrect. See: Lost Printer Settings When Name AutoCorrect Is Enabled at: http://support.microsoft.com/?id=240826 Turn off Name AutoCorrect. Compact the database. Open your report in design view, and save the correct margins. There are more than a dozen other bugs associated with Name AutoCorrect also: http://allenbrowne.com/bug-03.html Actually, just noticed you are printing a form, not a report. Would you consider saving the form as a report, and then printing that? It gives you much more control over the printing layout, and avoids messing with PrtMip. That's just a matter of selecting your form in the Database window, and choosing Save As. It's not easy to get PrtMip right. Microsoft got their example wrong in the Help files of Access 95, 97, and 2000, in different places. I haven't checked the more recent versions, but the knowledgebase/msdn articles have it right. -- Allen Browne - Microsoft MVP. Perth, Western Australia. Tips for Access users - http://allenbrowne.com/tips.html Reply to group, rather than allenbrowne at mvps dot org. "Steve Wright" wrote in message news:1089776996.479343@muldoon... Access seems to reset the print margins at random. I am looking for a way to set the margins when a form is opened. I assume that I need an On Open Event Proceedure and have written some code based on the stuff contained in the Access Help file but it refuses to run and gives the following error message. The expression On Open you entered as the event property setting produced the following error: Cannot define a public user-defined type within an object Module. * The expression may no result in the name of a macro, the name of a user-defined function, or [Event Proceedure]. * There may have been an error evaluation the function, event, or macro. Can some one help me out please? Code follows ================================================== ======= Option Compare Database Option Explicit Type str_PRTMIP strRGB As String * 28 End Type Type type_PRTMIP xLeftMargin As Long yTopMargin As Long xRightMargin As Long yBotMargin As Long End Type Private Sub Form_Open(Cancel As Integer) SetMarginsToDefault "F001 Carriageway Records" 'Name of the form End Sub Public Sub SetMarginsToDefault(strName As String) Dim PrtMipString As str_PRTMIP Dim PM As type_PRTMIP Dim rpt As Report DoCmd.OpenForm strName, acDesign Set rpt = Forms(strName) PrtMipString.strRGB = rpt.PrtMip LSet PM = PrtMipString PM.intLeftMargin = 0.3937 * 1440 ' Set margins. This gives 10mmm I think PM.intTopMargin = 0.3937 * 1440 PM.intRightMargin = 0.3937 * 1440 PM.intBotMargin = 0.3937 * 1440 LSet PrtMipString = PM ' Update property. rpt.PrtMip = PrtMipString.strRGB ' probably not needed if this runs every time the form is opened 'DoCmd.Close acForm, strName, acSaveYes End Sub ================================================== ========== |
#3
|
|||
|
|||
Setting Print Margins
The problem of reports that do not hold their margins can be traced to Name
AutoCorrect. See: Lost Printer Settings When Name AutoCorrect Is Enabled at: http://support.microsoft.com/?id=240826 Turn off Name AutoCorrect. Compact the database. Open your report in design view, and save the correct margins. There are more than a dozen other bugs associated with Name AutoCorrect also: http://allenbrowne.com/bug-03.html Actually, just noticed you are printing a form, not a report. Would you consider saving the form as a report, and then printing that? It gives you much more control over the printing layout, and avoids messing with PrtMip. That's just a matter of selecting your form in the Database window, and choosing Save As. It's not easy to get PrtMip right. Microsoft got their example wrong in the Help files of Access 95, 97, and 2000, in different places. I haven't checked the more recent versions, but the knowledgebase/msdn articles have it right. -- Allen Browne - Microsoft MVP. Perth, Western Australia. Tips for Access users - http://allenbrowne.com/tips.html Reply to group, rather than allenbrowne at mvps dot org. "Steve Wright" wrote in message news:1089776996.479343@muldoon... Access seems to reset the print margins at random. I am looking for a way to set the margins when a form is opened. I assume that I need an On Open Event Proceedure and have written some code based on the stuff contained in the Access Help file but it refuses to run and gives the following error message. The expression On Open you entered as the event property setting produced the following error: Cannot define a public user-defined type within an object Module. * The expression may no result in the name of a macro, the name of a user-defined function, or [Event Proceedure]. * There may have been an error evaluation the function, event, or macro. Can some one help me out please? Code follows ================================================== ======= Option Compare Database Option Explicit Type str_PRTMIP strRGB As String * 28 End Type Type type_PRTMIP xLeftMargin As Long yTopMargin As Long xRightMargin As Long yBotMargin As Long End Type Private Sub Form_Open(Cancel As Integer) SetMarginsToDefault "F001 Carriageway Records" 'Name of the form End Sub Public Sub SetMarginsToDefault(strName As String) Dim PrtMipString As str_PRTMIP Dim PM As type_PRTMIP Dim rpt As Report DoCmd.OpenForm strName, acDesign Set rpt = Forms(strName) PrtMipString.strRGB = rpt.PrtMip LSet PM = PrtMipString PM.intLeftMargin = 0.3937 * 1440 ' Set margins. This gives 10mmm I think PM.intTopMargin = 0.3937 * 1440 PM.intRightMargin = 0.3937 * 1440 PM.intBotMargin = 0.3937 * 1440 LSet PrtMipString = PM ' Update property. rpt.PrtMip = PrtMipString.strRGB ' probably not needed if this runs every time the form is opened 'DoCmd.Close acForm, strName, acSaveYes End Sub ================================================== ========== |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Print Margins in Word 2003 | Stina @ Work | General Discussion | 8 | April 23rd, 2005 06:57 AM |
Problems Setting Columns to Print | Kristen | General Discussion | 1 | July 15th, 2004 03:17 PM |
Print Margins changes on Multiple users | Steve | Setting Up & Running Reports | 2 | June 23rd, 2004 02:56 PM |
Print margins on Publisher 2003 | Chris | Publisher | 2 | May 5th, 2004 06:51 PM |
save setting for print entire workbook | Brian | Worksheet Functions | 2 | November 3rd, 2003 04:32 AM |