Results 1 to 6 of 6
  1. #1
    rlsublime is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Mar 2012
    Posts
    58

    On Error Message


    I am trying to add an on error messages to this code:

    I am trying to Display the message “The Output file is currently open. Please close and re-try” This should display when the file is open and the user tries to generate the file.

    Thanks


    Code:
     Private Sub Repurchase_Excel_Report_Click()
    If IsNull(Me!START_DATE.Value) Then
              MsgBox "Please Enter Start Date", vbOKOnly, "Start Date Missing"
              Cancel = True
              GoTo Err_Repurchase_Excel_Report_Click
           End If
           
    If IsNull(Me!END_DATE.Value) Then
              MsgBox "Please Enter End Date", vbOKOnly, "End Date Missing"
              Cancel = True
              GoTo Err_Repurchase_Excel_Report_Click
           End If
    On Error GoTo Err_Repurchase_Excel_Report_Click
    DoCmd.OutputTo acQuery, "Repurchase_Query", "MicrosoftExcel 97-10(*.xls)", "C:\Repurchase Report.xls", True, ""
        
        
    Err_Repurchase_Excel_Report_Click:
    Exit Sub
    End Sub

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    If you can identify the error number that is returned, you can trap for it:

    http://www.baldyweb.com/ErrorTrap.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    rlsublime is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Mar 2012
    Posts
    58
    thanks the error trapping worker perfectly. Is there a way to require a user to click at least 1 checkbox from a list of checkboxes. I am also looking for an on error message for that. Thanks for your help.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    I suspect you'll have to code that yourself. If they are stand-alone checkboxes, this type of thing:

    Code:
    If Me.Check1 = False And Me.Check2 = False Then
         Msgbox "Must select at least one"
         GoTo ExitHandler
    End If
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    rlsublime is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Mar 2012
    Posts
    58
    I tried both of these. It worked initially but now the message is not generating and not requiring the checkboxes. Is there something that I am missing? Thanks

    Code:
    If Me.chkbx_investor = False And Me.chkbx_makewhole = False And Me.chkbx_mi = False Then
    MsgBox "Please select at least one option from Request Type checkbox", vbOKOnly, "Repurchase Request Type Missing"
    GoTo Err_Repurchase_Excel_Report_Click
    End If
    Code:
    If Not (Me.investor1 Or Me.chkbx_mi) _
    Then
    MsgBox "Please select at least one Request Type", vbOKOnly, "Investor Request Type Missing"
    GoTo Err_Command20_Click
    End If

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    In case they could be Null, try


    If Nz(Me.chkbx_investor, 0) = False And Nz(Me.chkbx_makewhole, 0) = False And Nz(Me.chkbx_mi, 0) = False Then

    If that doesn't work, post the whole code. It seems odd to be going to your error handler.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Error message in tables!
    By sunshine in forum Access
    Replies: 1
    Last Post: 11-10-2011, 07:09 AM
  2. Error Message???????????
    By bopsgtir in forum Access
    Replies: 1
    Last Post: 10-02-2011, 06:10 PM
  3. Error Message
    By Juan4412 in forum Forms
    Replies: 5
    Last Post: 03-06-2011, 04:22 PM
  4. error message
    By ngeng4 in forum Forms
    Replies: 85
    Last Post: 03-25-2010, 06:47 AM
  5. If / Then Error Message
    By Schwagr in forum Forms
    Replies: 4
    Last Post: 03-30-2006, 06:28 AM

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