Printer definition changing?

I am using Access 2000.
when I create a report, and set the page margins to something other than the default, and copy the MDB to another PC, invariably I need to re-enter the page margins. Why is this?

And is there a way to set this from code so that I don't have to step the user through changing the page margin each time I send them a change?
tga243Asked:
Who is Participating?
 
sun365Connect With a Mentor Commented:
Hey, what you are looking for is all in a great book called Access 2000 Developer's Handbook Volumn I. It comes with a CD and it's in chapter 10! check it out, has the whole thing there.
I hope this helps.
0
 
BrianWrenCommented:
If you don't define a specific printer and setup for a report, Access uses the Windows default printer.

From Access Help:

You can use the PrtDevMode prp to set/return printing device mode info. specified for a form or report in the Print dlg.
You can use the PrtMip prp in VB to set/return the device mode info. specified for a form or report in the Print dlg.
You can use the PrtDevNames prp to set/return info about the printer selected in the Print dlg for a form or report.

As you can see, these three are closely related... But the point is that this gives you intimate control over the printer/printing, which you can utilize aggressively in you application. You can check for specific printers, set their device-specific properties, paper trays, sizes, margins, etc., with these properties.

Brian
0
 
tga243Author Commented:
Ok. I lookup the help on PrtDevMode and found an example to switch from Landscape to Portrate.

When I try running it, I get an error on


    Dim DM As type_DEVMODE

User-defind type not defined

I'm using access 2000 right out of the box. Is there something else that I need to install?
0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

 
tga243Author Commented:
Ok. I lookup the help on PrtDevMode and found an example to switch from Landscape to Portrate.

When I try running it, I get an error on


    Dim DM As type_DEVMODE

User-defind type not defined

I'm using access 2000 right out of the box. Is there something else that I need to install?
0
 
BrianWrenCommented:
You must put the following into a module in the declaration area, (select the Modules tab, click the New button, and make it look like what's below):

Option Compare DataBase
Option Explicit

Type str_DEVMODE
      RGB As String * 94
End Type

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



This will set up the User-Defined Type that your example requires.

Brian
0
 
BrianWrenCommented:
That looks awful!  (I guess tabs are no good...)

Option Compare DataBase
Option Explicit


Type str_DEVMODE
      RGB As String * 94
End Type


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



0
 
tga243Author Commented:
where does one find this?
0
 
BrianWrenCommented:
I got this straight out to the help file . . .

I typed in 'Prt', then selected 'PrtDevMode Property,' and went to the example.   The rest is posted above...

Brian
0
 
tga243Author Commented:
OK. Got the Orientation working, now how do I get the margins set??
0
 
BrianWrenCommented:
Type str_PRTMIP
    strRGB As String * 28
End Type

Type type_PRTMIP
    intLeftMargin As Integer
    intTopMargin As Integer
    intRightMargin As Integer
    intBotMargin As Integer
    intDataOnly As Integer
    intWidth As Integer
    intHeight As Integer
    intDefaultSize As Integer
    intColumns As Integer
    intColumnSpacing As Integer
    intRowSpacing As Integer
    intItemLayout As Integer
    intFastPrint As Integer
    intDatasheet As Integer
End Type

You can use the PrtMip property in to set or return the device mode info spec'd for a form/report in the Print dlg.

PrtMip setting is a 28-byte structure that maps to settings on the 'Margins' tab for a form/report in the Page Setup dlg.


Brian

0
 
tga243Author Commented:
Sorry to belabor this so much.
But I tried using the Type you gave me to change the margins with the following code. But ti doesn't work. What am I doing wrong?
Also, after opening the Report in Design mode and changed some of its settings, how do you save it programaticaly??



Function SetPrinterMargins(strName As String, intTop As Integer, intBottom As Integer, intLeft As Integer, intRight As Integer)

Dim DevString As str_PRTMIP

Dim DM As type_PRTMIP
Dim strDevModeExtra As String
Dim rpt As Report

' Opens report in Design view.
DoCmd.OpenReport strName, acDesign

Set rpt = Reports(strName)
If Not IsNull(rpt.PrtMip) Then
    strDevModeExtra = rpt.PrtMip
    DevString.strRGB = strDevModeExtra
    LSet DM = DevString
    DM.intLeftMargin = 1440 * intLeft
    DM.intRightMargin = 1440 * intRight
    DM.intBotMargin = 1440 * intBottom
    DM.intTopMargin = 1440 * intTop
   
    LSet DevString = DM            ' Update property.
    Mid(strDevModeExtra, 1, 28) = DevString.strRGB
    rpt.PrtMip = strDevModeExtra
End If

End Function
0
 
BrianWrenCommented:
It would be an enormous help if you told me what _does_ happen . . .
0
 
tga243Author Commented:
opens the report in design mode gives no error, no message, and makes no change to the Page Setup, Margin tab settings.

I should mention that after this line:
LSet DM = DevString
the top and bottom setting in MD.intRightMargin, etc are 1440 and the top and bottom are 0.

Then after it runs the next four lines each becomes 4320, but this does not reflect itself in the Page Setup, Margins

I was calling it like this: SetPrinterMargins("rep1",3,3,3,3)
0
 
tga243Author Commented:
Adjusted points to 75
0
 
tga243Author Commented:
Great. I had the book here, but forgot about it. I just got it out, and sure enought - it's all here!!!

0
 
nico5038Commented:
tga243,
Would be nice to see the real answer here for the people who don't have this book!
Could you add the ultimate solution that works ?!
0
 
doughtshCommented:
Chapter 10 is reproduced at http://www.microsoft.com/AccessDev/Articles/GetzCh10.HTM
(and I'm currently flushed with success at getting it to work!)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.