Results 1 to 14 of 14
  1. #1
    Lounger
    Join Date
    Mar 2001
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Form View Error Handling (2003)

    I have a field, Bag Number, where Indexed is set to Yes(No Duplicates). When entering data in table view an error is generated if a duplicate bag number is entered. When entering data in a form no error is generated when a duplicate bag number is entered. Is there a setting that will allow the same error to be generated on the form?

  2. #2
    4 Star Lounger
    Join Date
    Sep 2004
    Location
    Sacramento, California, USA
    Posts
    432
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Form View Error Handling (2003)

    When you entered the duplicate bag number on your form did you try to save the record? I don't see the message until an attempt is made to save the record. Are you asking to see the error message come up after a different action?
    Carla

  3. #3
    Lounger
    Join Date
    Mar 2001
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Form View Error Handling (2003)

    The record was saved but no error appeared. I only want the error to appear when the record is saved.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Form View Error Handling (2003)

    That is very strange. If there is a unique index on a table, you shouldn't be able to save a record with a duplicate value for the index, whether directly in the table or in a form based on the table. So you now have two records in the table with the same value in the index? <img src=/S/confused.gif border=0 alt=confused width=15 height=20>

  5. #5
    Lounger
    Join Date
    Mar 2001
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Form View Error Handling (2003)

    Even though an error message does not appear, the rule of the index does not allow a new record to be added with the same bag number. So there is only one record.

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Form View Error Handling (2003)

    First, you wrote "The record was saved but no error appeared", now "Even though an error message does not appear, the rule of the index does not allow a new record to be added". Which is it?

  7. #7
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Form View Error Handling (2003)

    Do you have a SetWarnings False anywhere in your form code or perhaps in a macro? Or do you have error handling like "On Error Resume Next"?
    Charlotte

  8. #8
    Lounger
    Join Date
    Mar 2001
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Form View Error Handling (2003)

    In table view an error message appears and the record is not added. On a form, no error message appears and the record is again not added. The user of this little app needs some notification that the record he is trying to add was not successful because of a duplicate bag number.

  9. #9
    Lounger
    Join Date
    Mar 2001
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Form View Error Handling (2003)

    Unless these two statements are added by default, they should not be anywhere in the form code.

  10. #10
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Form View Error Handling (2003)

    Could you post a stripped down copy of your database? See <post#=401925>post 401925</post#> for instructions.

  11. #11
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Form View Error Handling (2003)

    They aren't added by default, and they definitely should not be in your code, but it's the first thing to look for when you don't see an error message in a form.
    Charlotte

  12. #12
    Lounger
    Join Date
    Mar 2001
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Form View Error Handling (2003)

    Here you go.

    Thanks
    Hans

  13. #13
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Form View Error Handling (2003)

    The problem lies in the code behind the 'returntomenu' button. Because this has an On Error GoTo statement, errors while saving the record are suppressed (this is a bug in Access in my opinion). You can get around this by trying to save the record before closing the form (through the macro).

    Private Sub returntomenu_Click()
    On Error GoTo Err_returntomenu_Click

    Dim stDocName As String

    If Me.Dirty Then
    RunCommand acCmdSaveRecord
    End If

    stDocName = "Return to Menu"
    DoCmd.RunMacro stDocName

    Exit_returntomenu_Click:
    Exit Sub

    Err_returntomenu_Click:
    MsgBox Err.Description
    Resume Exit_returntomenu_Click
    End Sub

  14. #14
    Lounger
    Join Date
    Mar 2001
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Form View Error Handling (2003)

    Those three lines of code fixed the problem. Many thanks HansV

Posting Permissions

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