Link to home
Start Free TrialLog in
Avatar of Richard
Richard

asked on

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
ASKER CERTIFIED SOLUTION
Avatar of Scott McDaniel (EE MVE )
Scott McDaniel (EE MVE )
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Richard
Richard

ASKER

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 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
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.
Avatar of Richard

ASKER

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.

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.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
<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.
Avatar of Richard

ASKER

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
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