Merge Code Question

A

Albert D. Kallal

Try the test download...does it work ok?

If the test download works, then at least we eliminated that it is your
computer, or a bad/damaged
office install.

So, give the sample download a try. Does it work?

(try building a test template with the sample..and try a merge).

It is no use trying to get your code and application to work if the download
does not work...

So, lets concentrate on making the download function correctly. Once we
determined that the
download works, we can being the process of trying to make that sample work
in your application.

So, does the download work ok?
 
F

f2rox

The test download worked fine.
I played around with the pop-up and modal properties of the forms i had put
the merge buttons on. That seems to have fixed the problem.
Thanks
I was having some trouble with the printer change code on that website, too.
any chance you can help me with that? After changing the printer, i have it
print the form, then go back to default printer. If i cancel the printout at
any point, it does not go back to default printer. How can i fix this?
 
A

Albert D. Kallal

If i cancel the printout at
any point, it does not go back to default printer. How can i fix this?

Do you have error trapping? I mean, if the report is cancelled, that
has little to do with running some code to set the default printer.

Obviously, your will need to run code to set the printer back the default.

I would have to think that if your code that sets the default printer is
simply not being run.

You don't mention what version of ms-access, but for a2002 and later,
there is a built in printer object...so, you would not need my code

eg:

You don't mention what version\ of ms-access.

In access 2002 and later, there is a built in printer object, and it lets
you switch the printer with ease.

You can use:

Set Application.Printer = Application.Printers("HP LaserJet Series II")

The above means you don't need my code.

So, to save/switch, you can use:

dim strDefaultPrinter as string

' get current default printer.
strDefaultPrinter = Application.Printer.DeviceName

' switch to printer of your choice:

Set Application.Printer = Application.Printers("HP LaserJet Series II")

do whatever. --- print reports...etc...


Switch back.

Set Application.Printer = Application.Printers(strDefaultPrinter)
 
F

f2rox

I am using access 2003, so i am using the printer object, as explained on
your website:
' get current default printer.
strDefaultPrinter = Application.Printer.DeviceName

'switch to printer of your choice.
Set Application.Printer = Application.Printers("Microsoft Office Document
Image Writer")
DoCmd.PrintOut acSelection
Set Application.Printer = Application.Printers(strDefaultPrinter)

What can i do to switch back to the regular default printer even if i cancel
the printout from the image writer?
 
A

Albert D. Kallal

What can i do to switch back to the regular default printer even if i
cancel
the printout from the image writer?

Well, a quick fix would be to ignore errors....

try

on error resume next
DoCmd.PrintOut acSelection
Set Application.Printer = Application.Printers(strDefaultPrinter)

I suspect if the user cancels..then a error is generated, and you switch
back code don't run...

Further, if you don't trap a error, then ALL OF YOUR variables are lost. So,
any un-trapped errors means that all local (and global) variables are
re-set. (so, even if the code does run..the value of strDefaultPrinter is
lost).

So, you have to trap any and all errors in this case. While a bit lazy, the
use of resume next should do the trick in this case.....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top