Solved

Printer definition changing?

Posted on 2000-03-06
17
296 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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

863 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

22 Experts available now in Live!

Get 1:1 Help Now