?
Solved

Open PageSetup Using Code - Access 2000

Posted on 2009-04-29
13
Medium Priority
?
484 Views
Last Modified: 2013-11-28
I have an Access 2000 database which is used by multiple users, each with a different printer. A report can be produced from paper trays. Each user must change the report page setup to direct it to a partivular paper tray. The following code works well is I use Access 2007 to open the database but Access 2000 doesn't like it at all.

    DoCmd.SelectObject acReport, "rptP11D_Stage01_Individual", True
    DoCmd.RunCommand acCmdPageSetup
    DoCmd.SelectObject acForm, "frmReportSetup", False

Can anyone suggest the correct code? I wish to access the page setup from a button on a form. Thank you.
0
Comment
Question by:jonlake
  • 5
  • 4
  • 4
13 Comments
 
LVL 65

Expert Comment

by:rockiroads
ID: 24259571
wots the error in A2000? first two lines of your code works well in A2003
After opening page setup for the report, whats with the form call?
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 24259610
I tried this from a form

private sub mybtnOnForm_Click()
    DoCmd.SelectObject acReport, "rptP11D_Stage01_Individual", True
    DoCmd.RunCommand acCmdPageSetup
end sub


and it worked fine. Since I dont have A2000, perhaps its not supported then, so maybe open the report.

Question is why do each user need to setup their own? Is this a shared database?

Maybe it would be better if you split this into a front and back end database (if not aleady done so) and give each user their own frontend. That way there is no need to worry about changing this.


0
 
LVL 65

Accepted Solution

by:
rockiroads earned 1000 total points
ID: 24259643
in terms of what I said about opening, I was talking abut opening in preview mode then calling page setup then closing it
eg

    DoCmd.OpenReport "rptP11D_Stage01_Individual", acViewPreview
    DoCmd.RunCommand acCmdPageSetup
    DoCmd.Close acReport, "rptP11D_Stage01_Individual"

0
NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

 

Author Comment

by:jonlake
ID: 24259899
The system is split and each user has their own front end. It would normally be a one-off job to change the print setup for each user but this lot change printers like they change their pants, frequently!

I have attached the screen captures of the error and subsequent highlighted code.
Error-Message.jpg
Error-Highlight.jpg
0
 
LVL 74

Assisted Solution

by:Jeffrey Coachman
Jeffrey Coachman earned 1000 total points
ID: 24264051
Try inserting DoEvents, perhaps?

DoCmd.SelectObject acReport, "rptP11D_Stage01_Individual", True
DoEvents
DoCmd.RunCommand acCmdPageSetup
DoCmd.SelectObject acForm, "frmReportSetup", False

DoCmd.OpenReport "rptP11D_Stage01_Individual", acViewPreview
DoEvents
DoCmd.RunCommand acCmdPageSetup
DoCmd.Close acReport, "rptP11D_Stage01_Individual"


I'll test this on Access 2000 when I get home.

Jeff
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 24267081
jonlake,

Check your system buddy,

Both sets of code work fine for me in Access 2000, 2003 and 2007.

What version of Access was the database created in?

Does the code compile?

Run the copact/Repair utility.

JeffCoachman
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 24267087
Clarification:

"Both sets of code work fine for me in Access 2000, 2003 and 2007 with and without DoEvents"



0
 

Author Comment

by:jonlake
ID: 24267322
Thanks, I will confirm the details (and try the DoEvents component) when I get to work. It could be that we are running an old version which has not been patched/updated. Our IT guys hate Microsoft and so rarely update any MS software in preference to OpenOffice.
0
 

Author Comment

by:jonlake
ID: 24268839
I resolved my problem. To open the form in preview mode allowing use of PageSetup I used:

    DoCmd.OpenReport "rptP11D_Stage01_Individual", acViewPreview
    xg_MaximizeWindow "Access"
    Forms!frmP11D_AppendDirector.Visible = False

When the report is closed:

    xg_MinimizeWindow "Access"
    Forms!frmP11D_AppendDirector.Visible = True

I imported a module which allows excellent manipulation of windows etc. Ican be found using this link:

http://www.peterssoftware.com/winmanip.htm

Thank you all for your guidance.
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 24268883
So what I posted earlier

http://www.experts-exchange.com/Microsoft/Development/MS_Access/Q_24365056.html?cid=1066#a24259643

where I said to open report in preview mode
did the line still fail at page setup?

0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 24269005
OK, but again this worked fine for me without external software.
0
 

Author Comment

by:jonlake
ID: 24269555
Our version is SR1 which I presume cannot handle DoCmd.RunCommand acCmdPageSetup.

rockiroads - the preview worked but failed on DoCmd.RunCommand acCmdPageSetup.

By removing acCmdPageSetup I was able to preview but had to then handle my over zealouos use of modal forms to allow the user to update the report page setup. My system uses code to minimise and hide the access application which meant I had to maximise it, then minimise it again when closing the report.
0
 

Author Closing Comment

by:jonlake
ID: 31575881
Thank you all for your help. Whilst no single suggestion gave me the precise answer I needed, together they steered me in the right direction.
0

Featured Post

Transaction-level recovery for Oracle database

Veeam Explore for Oracle delivers low RTOs and RPOs with agentless transaction log backup and transaction-level recovery of Oracle databases. You can restore the database to a precise point in time, even to a specific transaction.

Question has a verified solution.

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

This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
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…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

839 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