access: trying specific printer to a report

dbse uploaded
go to form called Clients
go to tab Files
go to code behind  button Print file details
what I need to do is to tie the report triggered by that button to a label printer eg Dymo
i can do this through page set up but as there will be four people usijg the databse each with their own labeller then each will have to have their own separate button which is clumsy.
i understand the label printer will have to be decalred as an object but cant go any further.

max points for most helpful answer or the button coded for me which ever i am lucky enough to receice in your replies.

 Happy new year.

current.accdb
topUKlawyerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
You can set the Printer object at runtime:

Dim rpt As Report
DoCmd.OpenReport ReportName:="Customer Labels", View:=acViewPreview
Set rpt = Reports("Customer Labels")
rpt.Printer = Application.Printers("Label Printer")

(Note: Code above is from the linked article below)

Of course, if you don't know this beforehand, then you can't do it during Design. You could build a small form that shows the users the Printers, and then store this information somewhere (a table, or a database property) when they've made their selection.

See this article, which is written for 2002 but can be used in any version that exposes the Printer object:

http://msdn.microsoft.com/en-us/library/aa139946(v=office.10).aspx

There's a section titled
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SheilsCommented:
0
topUKlawyerAuthor Commented:
Thanks not sure what you mean by this:

Of course, if you don't know this beforehand, then you can't do it during Design.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

SheilsCommented:
I believe that you are trying to change the printer that the application uses. if you download the file from http://www.kallal.ca/msaccess/printch2k.zip and import the form and the module into your database, you and the user can use the for to select the desired printer
0
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
The code at Albert's site may work, but this was posted BEFORE Access introduced the Printer Object. You would be much better off using the builtin Printer Object to do this sort of thing (and Albert suggests this as well).

Note too that the code in Albert's site changes the DEFAULT Windows Printer, which can cause issues if you fail to change it back (or if something happens when you try to change it back). Using the Printer object in Access, you can change the Printer for only that report, and not muck around with the default Windows printer.

"Thanks not sure what you mean by this:

Of course, if you don't know this beforehand, then you can't do it during Design."

I mean that you cannot change the Printer during design, unless you know the exact name of each printer. You'd need to provide a method for the enduser to select their Printer for that report, and you'd then store that information somewhere and use it again, when they open the report again.
0
topUKlawyerAuthor Commented:
I think I might be on the wrong track as a runtime coded solution would presumably not work as each user will have their own label printer so It would be tricky to cater for each label printer acroos four or fiver users.

maybe the simple solution is just to ask the users to change to the labeller from their defualt printer each time they use the label button. that way they can change their individual labeller.

0
BadotzCommented:
Sorry if I'm stating the obvious (or stepping on anyone's toes) but if you can get the user name and their printer name, then you can hard-code the printer names into your form and automagically pick the correct one from the user's name at run-time.
0
Boyd (HiTechCoach) Trimmell, Microsoft Access MVPCommented:
I have used the code from this example with great success:

Programming Printer Settings in Microsoft Access 2002 and later

<<I think I might be on the wrong track as a runtime coded solution would presumably not work as each user will have their own label printer so It would be tricky to cater for each label printer acroos four or fiver users.>>

That should be very easy to handle.

I assume the database is slit with each user having their own copy of the front end.  Is this correct?

I use a table to store the printer to use for labels, checks, etc  by user and work station.  

The reports are set to use the default printer.

To print the report I use these steps:
1) save the current Application's default printer
2) look up the printer to use for this type or report
3) Application's default printer tot eh desired printer
4) print the report
5) change the Application's default printer back to the printer save in step 1

I run all my front ends with Access in Runtme mode and the above methods works great.



0
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
<I think I might be on the wrong track as a runtime coded solution would presumably not work as each user will have their own label printer>

The code I showed you earlier will change just the Report's printer as needed. If you store the value (in a table, perhaps), the user would need to select their label Printer only once, and your code would take over from there. This would be done during "runtime", not design.
0
topUKlawyerAuthor Commented:
LSM, is what you are saying that the user could eg select from a combo box their label printer

could it be done by a log in so that if it picks up the employees log in so that

if employee log in is 1 then code x
log in to then code y

etc
0
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
Sure - however you need to reference the printer and/or user would work. The workflow would be something like this:

1) User selects their label printer from a combo or listing (form created by you)
2) Your form stores that selection, in a table, logfile, registry, etc etc
3) When the user then opens that report, you look in your table, logfile, registry etc to find the correct name, and use the code as suggested above to set the Report Printer.

Note that you MUST use the DoCmd.OpenReport method for this to work. You cannot allow the user to open the report directly from the Nav Pane
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.