Results 1 to 7 of 7
  1. #1
    Join Date
    Feb 2009
    Posts
    3

    Unanswered: Change Access warning message

    I'm trying to open an append query via VBA and I want to modify the warning message that appears when some records can't be added. The statement "on error" does not work. How can I solve it???

    Thanks

  2. #2
    Join Date
    May 2005
    Posts
    1,191
    Welcome to the forums.

    Well if you don't want that warning to appear you can do like:
    Code:
    docmd.setwarnings false
    docmd.runsql ......
    docmd.setwarnings true
    Just make sure to do the setwarnings true in your errorhandling statement, and I usually do it on the exit procedure as well just to make sure. You do not want to leave that off by any means.
    Me.Geek = True

  3. #3
    Join Date
    Feb 2009
    Posts
    3
    Thanks nckdryr,

    I find the forums really interesting so you will see me more around here.

    I think I did not explain myself properly (maybe due to a language problem) but what I want is to replace the Access warning with another one of my own, not to avoid its appearance.

  4. #4
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    What is the error number are you receiving with "some records can't be added?"
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  5. #5
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    I think I did not explain myself properly (maybe due to a language problem) but what I want is to replace the Access warning with another one of my own, not to avoid its appearance.
    Then you will have to do it with VBA coding.
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  6. #6
    Join Date
    Feb 2009
    Posts
    3
    Quote Originally Posted by StarTrekker
    Then you will have to do it with VBA coding.
    That is what I am trying, but I do not know how.

  7. #7
    Join Date
    Jun 2007
    Location
    Maitland NSW,Australia
    Posts
    388
    Suppose you have the following code to append your query

    append_query_click()

    On Error GoTo Err_append_query_Click

    code to append query etc.

    Exit_append_query_Click:
    Exit Sub

    Err_append_query_Click:
    MsgBox Err.Description
    Resume Exit_append_query_Click

    Exit Sub

    The above will give a generic standard error message
    ***************************
    Now to find the error number for the error message, substitute the above Err_append_query_Click: code with

    Err_append_query_Click:
    MsgBox (" Form Error # " & str(Err.Number) & " was generated by" _
    & Err.Source & Chr(13) & Err.Description)
    Resume Exit_append_query_Click

    Note the error number when the message box is displayed.

    *************************************************
    Now you have the error number, you can do the following

    Err_append_query_Click:

    IF Err = the error number that was displayed THEN
    Msgbox "put your error message here"
    ELSE
    MsgBox Err.Description
    END IF
    Resume Exit_append_query_Click

    ***************************
    If multiple errors are displayed during the process you could use a Case statement as below

    Err_append_query_Click
    Select Case Err
    Case 3010
    MsgBox "The table " & strTarget & " already exists."
    Case 3078
    MsgBox "The table " & strSource & " doesn't exist."
    Case Else
    MsgBox CStr(Err) & " " & Err.Description
    End Select
    Resume Exit_append_query_Click

Posting Permissions

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