Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2010

    Unanswered: Print intermittently prints wrong object...

    Hi folks - using Access 2007. I have a little form that pops up so the user can enter some data, tick "Print Letter" or "Send Email" and then click "OK".

    My problem is with the Print option. On clicking "OK", I set the data to feed a Report which is the letter I want to print.

    What I want is for the Windows Print Dialog box to appear immediately, so the user can change the printer if they want to, click OK and get the letter printed.

    I don't want to have to ask the user to make menu selections or issue commands from the report preview - by clicking OK in the form they've already said they want to print, and I need to keep this simple and easy to use.

    The following code works 99% of the time ... but, just occasionally, it prints the form instead of the report. I've not been able to figure out the circumstances in which it gets it wrong - presumeably focus is being switched from the report to the form.

    Private Sub btnOK_Click()
    DoCmd.OpenReport "rptGenericLetter", acViewPreview
    DoCmd(dot)RunCommand acCmdPrint
    DoCmd.Close acReport, "rptGenericLetter"
    I tried using acViewNormal instead of acViewPreview, but it caused a print to go immediately to the default printer (and also printed a nearly blank page), which isn't what I want.

    There is a Report_Load() sub which runs when the report starts up (it does some calculations to get the contents right). I tried moving the DoCmd(dot)RunCommand acPrint to the end of that sub but it didn't work: the print dialog appeared but nothing was printed. Perhaps the Load event is too early??

    Is there a way that I can be sure that the RunCommand will apply to the Report, and not the Form that is calling it?

    Or another way of doing this?


  2. #2
    Join Date
    Mar 2010
    Adding to the above... I now realise that the idea of putting the Print inside the Report code somewhere isn't going to work for me, as there is another form in my program which calls up the same report but doesn't want to print it.

    Back to plan A ...

    Since my first post, I've used the Access Wizard to add a button to print my report, then auto converted the resulting macro to VBA, just to make the comparison. It created exactly the same code as I already had, which at least reassures me that I wasn't doing anything totally stupid.

    Any ideas as to why I sometimes get the wrong thing printed?

    Oh, and it's not a "Runtime" issue - the last time I saw this problem was definitely on a full-install copy.


  3. #3
    Join Date
    Nov 2004
    out on a limb
    Provided Answers: 59
    could be an interanl data error
    I'd take a backup
    then try to compile the project
    then perhaps comapct & repair.

    its sounds like a flaky internal issue rather than a code or design problem.
    I'd rather be riding on the Tiger 800 or the Norton

  4. #4
    Join Date
    Mar 2010
    Thanks for the response, but I don't think that's it. Last time it happened, I clearly remember just trying again straight away and it worked the second time, without repairing first.

    If it was just me using the system then I wouldn't worry about it, but I have to cater for some very un-confident users who I'd much rather didn't have to deal with this sort of problem.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts