Results 1 to 8 of 8
  1. #1
    Bronze Lounger
    Join Date
    Feb 2001
    Location
    Escondido, California, USA
    Posts
    1,458
    Thanks
    0
    Thanked 1 Time in 1 Post

    Program skips form (Access97 SR1)

    I added some code to the VBA Event Procedure for a command button that looks something like this:

    DoCmd.OpenForm stFormName, acNormal
    DoCmd.OpenReport stDocName, acPreview

    The form is designed to permit selection of certain records for printing.
    The code doesn't wait for an exit from the form before proceeding with the report. When the report is finished I find the form sitting there waiting for an exit. Is there something else I should do?

  2. #2
    Star Lounger
    Join Date
    Mar 2002
    Location
    Decatur, AL
    Posts
    53
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Re: Program skips form (Access97 SR1)

    I'm not sure I understand correctly, but it seems that you want the OpenReport command to be tied to a command button on the form from which you select the records for printing. What prints on the report as you have it now? Is stFormName the form that lets you select the records?
    Kathi

  3. #3
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Program skips form (Access97 SR1)

    I'm not entirely sure what you are trying to do, but if you open the form with the Windows Mode option set to acDialog (see Help in OpenForm method), it will wait for the form to close before the report executes.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  4. #4
    Bronze Lounger
    Join Date
    Feb 2001
    Location
    Escondido, California, USA
    Posts
    1,458
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Program skips form (Access97 SR1)

    Mark,

    I tried acDialog, but it didn't help. I see the form "blink" by and then the program proceeds to the print preview without waiting. When I quite the preview the underlying form is there.

    I didn't go into all the details, but what I have is a command button that previews (or another that prints) a report. Actually, I have two different reports that can be selected. I inserted code to first ask (i.e. MsgBox with a yes/no response) if they want a full report or only selected records. If they want selected records then prior to processing the DoCmd.Report I try to open up a separate form that lets them select the records they want to print (i.e. I have a check box field that lets them check or not check each record).

    The problem is that it opens the Form alright, but it immediately loses the focus (if that's the right term) and the code proceeds directly to the Report. When you exit the report, the Form appears waiting for you to exit it! So, the problem is that the program is not waiting for an exit from the form before proceeding to the report.

    I hope this clarifies what I'm trying to do.

  5. #5
    3 Star Lounger
    Join Date
    Jun 2001
    Location
    Maidstone, Kent, England
    Posts
    398
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Program skips form (Access97 SR1)

    Why not just remove the report command from your original code and give your users a print button on the new form for use when they have made their selections?

  6. #6
    Bronze Lounger
    Join Date
    Feb 2001
    Location
    Escondido, California, USA
    Posts
    1,458
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Program skips form (Access97 SR1)

    That sounds like a better approach. Thanks "Bat"

  7. #7
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Program skips form (Access97 SR1)

    >>I tried acDialog, but it didn't help. I see the form "blink" by and then the program proceeds to the print preview without waiting. When I quite the preview the underlying form is there.<<

    I can only conclude that you didn't specify the acDialog in the proper place in the OpenForm method. Make sure you have the right number of commas.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  8. #8
    Bronze Lounger
    Join Date
    Feb 2001
    Location
    Escondido, California, USA
    Posts
    1,458
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Program skips form (Access97 SR1)

    Thanks Mark,

    You are probably right; however, I finally decided that a better approach was to put command buttons on the form where one selects the records to be printed. That seemed easier on everyone (including me).

    I am still a novice at VBA, but I'm learning.

Posting Permissions

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