Solved

Make an Access97  Report Default to Legal size Landscape.

Posted on 1998-08-06
13
396 Views
Last Modified: 2011-04-14
I have a application I created in Access 97 & have it loaded on the server with 5+ stations using it.  They all have a local printer & a network printer.  They use local printer for small print jobs & network for larger ones. My problem is, I have reports that run on Legal size paper Landscape.  But when they change printers, it resets the reports to letter size landscape.  Is there a way to stop this?  Can it be automaticly set set no matter if you change printers?  This would seem like an easy answer but I can't figure it out!
Any help is appreciated.
Thank you.

Ed W.
0
Comment
Question by:ewalsh
  • 6
  • 5
  • 2
13 Comments
 
LVL 5

Expert Comment

by:kulikuli
ID: 1958310
Check the defaultview property in the form's property sheet to have a form displayed in datasheet view

Best regards,

kulikuli
0
 
LVL 5

Expert Comment

by:kulikuli
ID: 1958311
sorry for that comment - I posted it in the wrong question
0
 
LVL 1

Accepted Solution

by:
sfranks earned 30 total points
ID: 1958312

Here ya go....   you can just add this code to the onPrint event of the report.

If this doesn't work or you have problems just let me know.

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

Sub SwitchOrient(strName As String)
      Const DM_PORTRAIT = 1
      Const DM_LANDSCAPE = 2
      Dim DevString As str_DEVMODE
      Dim DM As type_DEVMODE
      Dim strDevModeExtra As String
      Dim rpt As Report
      DoCmd.OpenReport strName, acDesign   ' Opens report in Design view.
      Set rpt = Reports(strName)
      If Not IsNull(rpt.PrtDevMode) Then
        strDevModeExtra = rpt.PrtDevMode
        DevString.RGB = strDevModeExtra
        LSet DM = DevString
        DM.lngFields = DM.lngFields Or DM.intOrientation      ' Initialize fields.

If DM.intOrientation = DM_PORTRAIT Then
                  DM.intOrientation = DM_LANDSCAPE
            End If
            LSet DevString = DM                                    ' Update property.
            Mid(strDevModeExtra, 1, 94) = DevString.RGB
            rpt.PrtDevMode = strDevModeExtra
      End If
End Sub

0
 

Author Comment

by:ewalsh
ID: 1958313
When I put this code in a Sub Procedure in Event "OnPage" of my report I get this error message.

Compile Error:Invalid Inside Procedure.

It is then highlights this line of code:

Type str_DEVMODE

Help!
0
 
LVL 1

Expert Comment

by:sfranks
ID: 1958314
Not too familiar with VBA eh....    alright then.....  

Okay well when I said that you should add this code to the onPrint event what I meant
really was a call to this code.  So in the onPrint event you should say

call SwitchOrient("YourREPORTName" As String)

the rest of the code should be put into a module so....

go to the module tab.....  click new....  copy the code that I previously gave you and
paste it after the option explicit statement.  That should be it....  


0
 

Author Comment

by:ewalsh
ID: 1958315
Ok, I made a module & saved it as "Print on Legal paper and Landscape.

I put call SwitchOrient("rptVT_Others" As String) in OnPrint.
And ran it.  Got an error message.
"Diary Daily Reports can't find the Macro."

I then tried
=call SwitchOrient("rptVT_Others" As String)
=SwitchOrient("rptVT_Others" As String)
SwitchOrient("rptVT_Others" As String)

No luck, same error message.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 1

Expert Comment

by:sfranks
ID: 1958316
oppps, sorry about that.  Just add the keyword "public" before the sub procedure.

0
 

Author Comment

by:ewalsh
ID: 1958317
Ok, I made a module & saved it as "Print on Legal paper and Landscape.

I put call SwitchOrient("rptVT_Others" As String) in OnPrint.
And ran it.  Got an error message.
"Diary Daily Reports can't find the Macro."

I then tried
=call SwitchOrient("rptVT_Others" As String)
=SwitchOrient("rptVT_Others" As String)
SwitchOrient("rptVT_Others" As String)

No luck, same error message.
0
 
LVL 1

Expert Comment

by:sfranks
ID: 1958318
Ack!  Too much cut, copy, paste.  

Call SwitchOrient("rptVT_Others")

0
 

Author Comment

by:ewalsh
ID: 1958319
Ok, I placed Call SwitchOrient("rptVT_Others") in OnPrint.

I saved it & tried to run it. I get this error message.
Run-Time Error '2046':
The command or action 'OpenReport'  isn't available now.
I then click DEBUG button & this line of code is highlighted.

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

If it makes a difference.  The table that this report is getting its info from is a Linked Foxpro 2.5 Table.  I have full rights to it.

Ed W.
0
 

Author Comment

by:ewalsh
ID: 1958320
One other note.

OnPrint Event.  I noticed that this event can be different for different Sections of the report. Ect, Page header/Footer, Report Header Footer,GroupHeader/GroupFooter ect.
Where should it go?
In the events for the whole report there is no OnPrint Event.
Only:
On Open, On Close, On Activate, On DeActivate, On NoData, On Page, On Error.

I'm a bit confused on the proper place to put the
Call SwitchOrient("rptVT_Others").
0
 
LVL 1

Expert Comment

by:sfranks
ID: 1958321
just comment out that line...   I don't think you actually have to open the report.


0
 
LVL 1

Expert Comment

by:sfranks
ID: 1958322
hmmmm,  I would try the report header onPrint event.  
0

Featured Post

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.

Join & Write a Comment

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

743 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

10 Experts available now in Live!

Get 1:1 Help Now