Solved

Printer definition changing?

Posted on 2000-03-06
17
280 Views
Last Modified: 2012-06-21
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?
0
Comment
Question by:tga243
17 Comments
 
LVL 9

Expert Comment

by:BrianWren
ID: 2588983
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
 

Author Comment

by:tga243
ID: 2589690
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
 

Author Comment

by:tga243
ID: 2589713
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
 
LVL 9

Expert Comment

by:BrianWren
ID: 2589724
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
 
LVL 9

Expert Comment

by:BrianWren
ID: 2589729
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
 

Author Comment

by:tga243
ID: 2589802
where does one find this?
0
 
LVL 9

Expert Comment

by:BrianWren
ID: 2589928
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
 

Author Comment

by:tga243
ID: 2590387
OK. Got the Orientation working, now how do I get the margins set??
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 9

Expert Comment

by:BrianWren
ID: 2592401
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
 

Author Comment

by:tga243
ID: 2593838
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
 
LVL 9

Expert Comment

by:BrianWren
ID: 2593881
It would be an enormous help if you told me what _does_ happen . . .
0
 

Author Comment

by:tga243
ID: 2594071
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
 

Author Comment

by:tga243
ID: 2594639
Adjusted points to 75
0
 
LVL 2

Accepted Solution

by:
sun365 earned 75 total points
ID: 2601364
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
 

Author Comment

by:tga243
ID: 2601858
Great. I had the book here, but forgot about it. I just got it out, and sure enought - it's all here!!!

0
 
LVL 54

Expert Comment

by:nico5038
ID: 2603420
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
 

Expert Comment

by:doughtsh
ID: 7821417
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

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now