Results 1 to 9 of 9
  1. #1
    4 Star Lounger
    Join Date
    Aug 2001
    Location
    London, UK
    Posts
    516
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Warnings off (Access2k)

    How can I set the warning off when I run action queries using codes??
    I am already using the following code but it doesn't seem to work:
    'Turn System warnings off
    DoCmd.SetWarnings False
    PLEASE <img src=/S/help.gif border=0 alt=help width=23 height=15>
    <img src=/S/bow.gif border=0 alt=bow width=15 height=15>

  2. #2
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    1,862
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Warnings off (Access2k)

    How are you running the query? Is it with DoCmd.OpenQuery....?

    I usually use:<pre>DoCmd.SetWarnings False
    DoCmd.RunSQL "UPDATE/DELETE....." 'whatever
    DoCmd.SetWarnnigs True</pre>

    In theory, of course, either way should work correctly. I don't really like leaving action queries visible in the database window. I just don't trust end users so I either hide the action query or write it in code (as above).

    HTH <img src=/S/salute.gif border=0 alt=salute width=15 height=20>

  3. #3
    4 Star Lounger
    Join Date
    Aug 2001
    Location
    London, UK
    Posts
    516
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Warnings off (Access2k)

    This is how am doing it, and I have the DoCmd.SetWarnings false command but it doesn't seem to work <img src=/S/confused.gif border=0 alt=confused width=15 height=20>
    Sub ImportSecData()
    Dim db As DAO.Database
    Dim rst As DAO.Recordset
    Set db = CodeDb
    'Turn System warnings off
    DoCmd.SetWarnings False
    'Create table in Tradar.mde and link that table to TrdSdk.mde
    DoCmd.RunMacro "mcrLinkTblData", , ""
    'Delete old data and import new data
    DoCmd.OpenQuery "DELtblData", acNormal, acEdit
    DoCmd.TransferSpreadsheet acImport, 8, "tblData", "T:TradeAdminSysSecData.xls", True, ""
    Set rst = db.OpenRecordset("tblData")
    If rst.BOF And rst.EOF Then
    MsgBox "Data has not been imported from SecData.xls, Please check and try again!", vbInformation + vbMsgBoxSetForeground, strMsgTitle
    Else
    MsgBox "Data has been imported!", vbInformation + vbMsgBoxSetForeground, strMsgTitle
    DoCmd.OpenQuery "UpdSecTT", acNormal, acEdit
    DoCmd.OpenQuery "UpdSec", acNormal, acEdit
    'Add last tnum
    DoCmd.OpenQuery "DELTnum", acNormal, acEdit
    DoCmd.OpenQuery "AppTnum", acNormal, acEdit
    DoCmd.OpenForm "frmTnum", acNormal, "", "", acEdit, acNormal
    End If
    'Turn System warnings on
    DoCmd.SetWarnings True
    End Sub

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

    Re: Warnings off (Access2k)

    What doesn't work and what kind of error or misbehavior are you seeing. Without that information, noboby can give you a useful answer.
    Charlotte

  5. #5
    4 Star Lounger
    Join Date
    Aug 2001
    Location
    London, UK
    Posts
    516
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Warnings off (Access2k)

    The DoCmd.SetWarnings.False isn't working coz its displaying all the messages that you'd normally get when you run an action query.

  6. #6
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    1,862
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Warnings off (Access2k)

    By chance, does your Macro ("mcrLinkTblData") have the "SetWarning=True" command in it?

  7. #7
    Bronze Lounger
    Join Date
    Nov 2001
    Location
    Arlington, Virginia, USA
    Posts
    1,394
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: Warnings off (Access2k)

    You can also use the Application SetOption method to turn off action query warnings:
    <pre>Application.SetOption "Confirm Action Queries", False</pre>

    However, the DoCmd.SetWarnings False should work too.

  8. #8
    Star Lounger
    Join Date
    Apr 2001
    Location
    Melbourne, Australia
    Posts
    53
    Thanks
    2
    Thanked 1 Time in 1 Post

    Re: Warnings off (Access2k)

    >> The DoCmd.SetWarnings.False isn't working coz its displaying
    >> all the messages that you'd normally get when you run an action query.

    There are different classes of messages, so it would be helpful to give an example.

    One type of message that is not an error, and is not trappable, is that which is displayed if you try to run an action query that cannot succeed because of "invalid" data - for example, which would result in duplicate index keys, etc. If it is these that you are seeing, you need to code round that by using a different type of query. If it is the type of message asking for confirmation to execute the query, you have a different problem.

    Geoff

  9. #9
    4 Star Lounger
    Join Date
    Aug 2001
    Location
    London, UK
    Posts
    516
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Warnings off (Access2k)

    Thanx guys.
    <img src=/S/bow.gif border=0 alt=bow width=15 height=15>

Posting Permissions

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