Microsoft Access
--
Questions
--
Followers
Top Experts
In configuring the page settings for a form...or actually a couple of forms...within MS Access, what is the best way to do this with VBA?
The form settings needed are Margins (all), Orientation, Printer Name, and Paper Size (30256 Shipping). Â Currently this is being done by selecting the Form (or highlighting the Form Name) and clicking on Page Setup in the QAT.
Thanks..
Zero AI Policy
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
I don't mean to be obtuse, but "Report" and "Form" are distinct objects in Access, and are managed differently. It's important to use the correct terms in an online forum, since we have no way of knowing what you see onscreen, and must rely only on what you write.
That said: the only way to modify Page settings and such for a Report is to open that report in Design view. Even if you have a dozen Reports that need to be modified, opening each of those manually and editing the properties would be much quicker than developing code to do it.
If you want to do that at runtime ... just don't. In order to do that you must deploy the .accdb/.mdb file, and everytime you make those changes your file will decompile. This can lead to bloat, performance issues, etc etc.






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
I was able to find some Access code that would list all of the installed Printers on the system. Â But, I'm looking for a way to set the Dymo_Label1_Form and the Dymo_Lalabel2_Form with Dymo as the Specific Printer, Margins needed, Landscape Orientation, and the Paper size set to "30256 Shipping." Â The same type of settings are needed for the Zebra_Label1_Form and Zebra_Label2_Form.
From what I understand in your response is that there is no way to do this in VBA. Â Although, to perform the Page Setup, all that is needed is to highlight the form, select Page Setup, and set the parameters...no opening of the form is necessary.
Does Access have a back-door way to Record a Macro?
A Form does not have the Page Setup option, nor does it have Margins, etc. A Report has this, but you continue to insist you're using a Form.
You can use the Printer Object to perform many of these things during runtime. Â You would do something like this;
dim prt As Printer
Set prt = Application.Printers("Your
prt.BottomMargin = "0.5"
prt.TopMargin = "0.5"
etc etc
AFTER setting your Printer object, you would then print the report as needed. Assuming your report is set to use the correct printer (or the Default Printer) you should be good.
You can store printer-specific settings in a Table in the database, and you could read those settings as needed, for the specific printer.
PrinterObject;
https://msdn.microsoft.com/en-us/library/office/ff837177.aspx?f=255&MSPPError=-2147217396
Making the settings for a specific printer, doesn't seem to tie a particular form to a specific printer. Â It may possibly default to the printer, but the page settings or margins are not carried through so the Labels are printed properly.

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
If what you want is printed output, you should be using a report. Â You can convert the forms to reports and that will probably give you more success. Â Open each form in design view and choose the save as option. Â You can choose to save them as reports. Â Once the forms have been converted to reports, you will have better control over printing them.
We having been using this application for several years now and this is what we have. Â
If it's not possible to set the Page Setup parameter's for each form...why are we able to do so?
If you take a look at what I posted, the form is not open. This is how we  configure the page settings for each of the forms that need to be setup for use by a printer. First we have to put the Page Setup function on the QAT, as it is not available  within the standard toolbar.
It is currently a "pain," to have to manually set each Form's Page Setup.
How many forms would need to be converted to reports? Â I think that is going to be your path to success.






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
Well, I would hate to disagree on a matter in which I'm requesting some assistance, but below is a Form, with the specific Page Setup information for it.
First we have to put the Page Setup function on the QATThat's why you see it and we don't. You modified the QAT to show the basic Page Setup feature, which would configure the settings for the default printer.
The VBA I suggested should do this for you, but you cannot set these for each Form. You'd have to use the methods I suggest if you want to try and automate this.
We having been using this application for several years now and this is what we haveWe hear that quite a bit, but the answer is always - do it the right way, whether it's been working or not. As both Pat and I have said: Reports are for printing, not forms. While you can sometimes work around these issues, you'll inevitably find something that won't work.
If all that is needed is to set the parameters for the installed printer, how then should the code be written. It needs to loop through the installed printers, if it finds one that begins with "Dymo", it will set the appropriate configuration for it, and if it begins with "Zebra", another configuration is applied?

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
Remember, when you put that setup button on the QAT, you DID NOT get it from the form ribbons. Â You got it from the report ribbons. Â That should be a clue.
If a Form is built like a label, and printed on a physical label from label printer, is this not printing from a Form? Maybe I'm just not understanding this.Not in the Access world (at least not in my Access world). You're "printing a Form", not "printing from a Form".
As I mentioned earlier, you can use the Printer object to cycle through all the settings for the default printer, or for any printer in the system that Access recognizes. To cycle through printers:
Dim prt As Printer
For each prt in Application.Printers
 If prt.Name= "SomeName" then
  <modify settings here>
 End If
Next prt
Note this would make those changes for the session of Access, and those changes would not "stick". You'd have to run this each time the application opens. If you want the changes to stick, you'd have to convert your forms to reports, then open each report in Design view and make the changes, and then save them.
But you can't do that with a Form, since a Form doesn't have any method for doing that.
Would you please comment on the Microsoft pages:
"How to: Work with Form and Report Printer Settings"...and "How to set...."
   https://msdn.microsoft.com/en-us/library/office/ff845464(v=office.14).aspx
  https://msdn.microsoft.com/en-us/library/office/ff191806(v=office.14).aspx
One example they use is for a Report...but what would be the syntax for a specific Form, "Form_ShipLabelDymo?"






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
Microsoft Access
--
Questions
--
Followers
Top Experts
Microsoft Access is a rapid application development (RAD) relational database tool. Access can be used for both desktop and web-based applications, and uses VBA (Visual Basic for Applications) as its coding language.