473,378 Members | 1,409 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Code not running correctly from form

Hello all,

I have a form in Access XP that returns all printers installed on the
user's system. They select which printer they want to print to and
click a "Next" button. The button click event runs the code posted at
the bottom of this message to open a number of reports, change the
printer to the one the user specified, save and close, then print the
reports.

The code runs fine if run directly within the module, but when it's
fired from a click event in a form the report prints to whatever
printer was previously saved in the report.

I have repaired and decompiled, any other thoughts? Thanks in advance
for any advice you may have.

code:

Public Sub sChangePrinter(strReport As String, strDeviceName As String,
Optional strOrientation, Optional strPaperSize)

Dim rpt As Report
DoCmd.OpenReport strReport, acViewPreview
Set rpt = Reports(strReport)
rpt.Printer = Application.Printers(strDeviceName)
rpt.Printer.Orientation = strOrientation
rpt.Printer.PaperSize = strPaperSize
DoCmd.Close acReport, strReport, acSaveYes
rpt.Printer = Application.Printers(strDeviceName)
rpt.Printer.Orientation = strOrientation
rpt.Printer.PaperSize = strPaperSize
DoCmd.Close acReport, strReport, acSaveYes
DoCmd.OpenReport strReport, acViewNormal

End Sub

Nov 13 '05 #1
0 1164

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Bruce A. Julseth | last post by:
I'm a newbie to PHP and am have problems getting simple PHP page (php_test_page.php) to display correctly. The page is: <html> <body>
0
by: Paul C | last post by:
Hello, everybody. I am having trouble running some of the VS.NET samples, specifically the CarSelector web app, which is very simple. The symptom is that the web controls (drop down listboxes and...
2
by: Douglas Buchanan | last post by:
I set the OnExit property of the "Cost" field in subform "subJobDetail" to save the record (see below). Then I call a global sub to copy the )] calculated field to a field in the subform "subJob"....
5
by: MLH | last post by:
Having identified a A97 bug in which acDialog causes undesirable side effects processing the opened form, I would like to replace the following code running in MyForm ... DoCmd.OpenForm...
2
by: Don Munroe | last post by:
This one has me stumped. I have three web applications running on two different servers. The first that works fine is hosted by a .Net hosting company. Everyone that uses it has no problems...
10
by: Don Munroe | last post by:
This one has me stumped. I have three web applications running on two different servers. The first that works fine is hosted by a .Net hosting company. Everyone that uses it has no problems...
15
by: Cheryl Langdon | last post by:
Hello everyone, This is my first attempt at getting help in this manner. Please forgive me if this is an inappropriate request. I suddenly find myself in urgent need of instruction on how to...
5
by: Easystart | last post by:
Hi, Sorry for my English. English is not my native tougue. I am working in MS Access 2000 with a SQLServer 2000 Backend database. MS Access 2000 is my GUI front end that has SQLServer linked...
8
by: Simon | last post by:
Dear reader, The syntax for the VBA code to change the RowSource of a Form is: Forms!FormName..RowSource = "TableOrQueryName"
7
by: =?Utf-8?B?U2hpdmEgUmFtYW5p?= | last post by:
I have a windows application with multiple forms & another web application. Now I need a parent EXE or Application which need to act as a container to these application. Example : My existing Web...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.