Results 1 to 2 of 2
  1. #1
    Heatshiver is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2011
    Posts
    128

    Question Need to Circumvent general Microsoft Access Error?

    I have a field to input a User ID. It is validated by another table where all the User ID's are stored. The code I have inserted works and makes sure that the user receives a message to describe the problem:

    Private Sub UserID_AfterUpdate()

    If IsNull(DLookup("UserNum", "tblUsers", "UserNum = '" & [Forms]![frmGenSum]![UserID] & "'")) Then
    MsgBox "Please input a valid User ID."
    [Forms]![frmGenSum]![UserID] = ""
    Else
    'Do Nothing
    End If



    End Sub

    The problem I am having is that Microsoft has its own error message after mine: "You cannot add or change a record because a related record is required in table 'tblUsers'." I need to a way to avoid the Microsoft statement altogether. I was trying On Error GoTo and then the If statement, but it still comes up.

    What VBA coding can I use to circumvent this? Thanks for the help.

  2. #2
    Heatshiver is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2011
    Posts
    128
    Figured out a solution.

    I technically don't need to place the code in the text box because I have a save button. If I just use the save button, the error does not appear.

    However, I have no exit button on the form, and in order to get away from that form the user must use the Back button which closes the form.

    I also had to set the form itself to cycle only through the record it was in, otherwise it would try to get to a new record and then give the error.

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

Similar Threads

  1. Replies: 9
    Last Post: 06-08-2012, 07:52 AM
  2. Replies: 15
    Last Post: 05-02-2012, 09:13 AM
  3. Replies: 1
    Last Post: 09-13-2011, 01:52 PM
  4. Microsoft Access Error 3071
    By Ev0luTioN in forum Access
    Replies: 1
    Last Post: 08-04-2010, 04:35 PM
  5. Replies: 1
    Last Post: 03-02-2010, 03:01 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