Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Cornwall, England
    Posts
    393
    Thanks
    0
    Thanked 0 Times in 0 Posts

    No Warnings but Errors (XP)

    Hi, just a quckie i hope.

    i am running an insert statement and rather than annoy the user i am turning off the warnings via:
    DoCmd.SetWarnings False
    DoCmd.RunSQL <<strSQL>>
    DoCmd.SetWarnings True

    I would like however to warn the user if the insert fails (duplicate rows etc)

    how can i trap this if the SetWarnings is False?


    TIA

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

    Re: No Warnings but Errors (XP)

    Replace

    DoCmd.SetWarnings False
    DoCmd.RunSQL <<strSQL>>
    DoCmd.SetWarnings True

    with

    CurrentDb.Execute strSQL, dbFailOnError

    You won't get prompted whether you want to append records, but you will see error messages (which you can trap the normal way with an On Error handler)

  3. #3
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Cornwall, England
    Posts
    393
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: No Warnings but Errors (XP)

    ideal solution, many thanks.


    <<off to hunt down all docmd.runsql statements and replace them ... >>

Posting Permissions

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