Page 3 of 3 FirstFirst 123
Results 31 to 38 of 38
  1. #31
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Two approaches.



    1) Re-open the appointmentschedulerfrm in the Close event of the report, which will happen with NoData as well.

    2) This is untested but should also work and my preferred method:

    Code:
    Private Sub Command6_Click()
    On Error GoTo Command6_Click_Err
    ' Hide this form while report is open
    Me.Visible = False
     'Preview a Report
          DoCmd.OpenReport "appttblstaffdateselectedrpt", acViewPreview, "", "", acDialog'previews report
    '
    'With the the WindowMode of acDialog, the OpenReport command will keep this form open (hidden if you like) and halt the code
    'execution in this form right here. When the report completes ir is made invisible, code execution begins agaun right here.
    '
    Me.Visible = True
    'Print a Report
       ‘           DoCmd.OpenReport "appttblstaffdateselectedrpt", acViewNormal, "", "", acDialog       'prints report
    Command6_Click_Exit:
        Exit Sub
    Command6_Click_Err:
            MsgBox "An error has occurred. Please start over. ", vbOKOnly, ""
    
    
             'DoCmd.Close        'closes current form
        'DoCmd.OpenForm "appointmentschedulerfrm", acNormal, "", "", , acNormal                 'opens form
     
        Resume Next
     
    End Sub
    Please ask questions if you have some.

  2. #32
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    The advantage of using the acDialog parameter is that the Report does NOT need to know who called it. It just exits and goes back to whatever called it.

  3. #33
    Roncc is offline Advanced Beginner
    Windows 10 Access 2010 32bit
    Join Date
    Dec 2017
    Posts
    85
    I just did. See my post #29

  4. #34
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Quote Originally Posted by Roncc View Post
    I just did. See my post #29
    Got 'em, thank you.

  5. #35
    Roncc is offline Advanced Beginner
    Windows 10 Access 2010 32bit
    Join Date
    Dec 2017
    Posts
    85
    I placed the code DoCmd.OpenForm "appointmentschedulerfrm", acNormal, "", "", , acNormal in the close event of the report. I then placed the code you presented in the click event of the button that tells the report to print. I still get the error.

    Ron C

  6. #36
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Comment out the code in the Close event of the report. It should only be in one place.

  7. #37
    Roncc is offline Advanced Beginner
    Windows 10 Access 2010 32bit
    Join Date
    Dec 2017
    Posts
    85
    Didn't work. I've found that if I place the following code in the OnError event for the button the error message does not display.

    MsgBox "An error has occurred. Please start over. ", vbOKOnly, ""
    DoCmd.SetWarnings False
    'MsgBox Err & " " & Error$ ‘this captures the error code
    DoCmd.Close 'closes current form
    DoCmd.SetWarnings True
    DoCmd.OpenForm "appointmentschedulerfrm", acNormal, "", "", , acNormal 'opens form


    I think I'll go with that. Thanks for all the help. I really appreciate all the time you and the others have provided to assist me.

    Ron C

  8. #38
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Go with what works. Have fun.

Page 3 of 3 FirstFirst 123
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Run-time error 2501 for one user on one PC
    By TheBradish in forum Access
    Replies: 11
    Last Post: 06-13-2017, 04:02 AM
  2. Error 2501
    By Abacus1234 in forum Forms
    Replies: 3
    Last Post: 09-08-2015, 04:46 PM
  3. Do.cmd OutputTo Error 2501
    By Fuzz_cozens in forum Programming
    Replies: 7
    Last Post: 07-15-2014, 06:44 AM
  4. Error Handling 2501
    By RainyDay in forum Programming
    Replies: 7
    Last Post: 06-08-2013, 10:44 PM
  5. Error 2501 displays with Error handling
    By agent- in forum Programming
    Replies: 13
    Last Post: 08-05-2011, 02:20 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums