Results 1 to 6 of 6
  1. #1
    Join Date
    Aug 2011
    Posts
    4

    Question Unanswered: Disable Warning Messages

    I am having a problem with my work database because due to the complexity of the queries / macro's etc...whenever I run the update button a vast number of warning messages pop up.

    The button is linked to a macro which runs 6 make-table queries.

    The problem I have is because I did not create the database, I have no idea where to start to turn these warnings off.

    On investigating, I am told that the following code would sort it out, however, I have no idea where to put this code!

    Private Sub cmdRunMakeTable_Click()
    DoCmd.Hourglass True
    'Turns off the Access warning messages
    DoCmd.SetWarnings False
    DoCmd.OpenQuery "mktqry_MakeNewTable"
    DoCmd.Hourglass False
    'Turns the Access warning messages back on
    DoCmd.SetWarnings True
    End Sub

    I did try and put the code into the SQL each query but SQL does not appear to like this Syntax.

    If anyone could help me, that would be appreciated.

  2. #2
    Join Date
    Oct 2003
    Location
    London
    Posts
    341
    The two following commands relate to turning the warnings off, and on.

    Code:
    DoCmd.SetWarnings False
    DoCmd.SetWarnings True
    Switch them off at the beginning of your command, and switch them back on just before the end sub.

    What is the command behind the OnClick of your button?

  3. #3
    Join Date
    Aug 2011
    Posts
    4
    when looking at the back drop of the button, it just takes me to the macro builder screen where I can see the 6 queries that the button is trying to run. I have looked in visual basic but cannot see any code relating to this button (hence why I am confused!) can you give me a step by step of where I should look? I have attached a print screen of the macro page.
    Incidentally I am able to look at the SQL for each individual query listed in the macro but I do not know how to write or edit code in this format.
    An example of the SQL code is as follows:

    SELECT dbo_ITT1.Father, dbo_OITM.ItemName, dbo_OITM.U_CustName, dbo_ITT1.Code, [dbo_itt1]![quantity]/[dbo_oitt]![qauntity] AS Qty INTO [Bill of Materials3]
    FROM (dbo_ITT1 LEFT JOIN dbo_OITM ON dbo_ITT1.Father = dbo_OITM.ItemCode) LEFT JOIN dbo_OITT ON dbo_ITT1.Father = dbo_OITT.Code
    ORDER BY dbo_ITT1.Father;Hope this makes sense! Thanks for your help.
    Attached Files Attached Files

  4. #4
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    If the queries are open by a macro, open it in design mode and place this on the first line of it (before the instructions OpenQuery):
    Code:
    Action: SetWarnings
    Argument (Warnings On): No
    Dont forget to also add a final instruction to the macro to reset the warnings to Yes.
    Have a nice day!

  5. #5
    Join Date
    Aug 2011
    Posts
    4
    thank you, you are a star!! I did have an issue because my 'SetWarnings' option was not showing but I discovered that access 2007 hide this for security reasons.

    For anyone else who may encounter this problem, just click on 'Show All Actions' at the top of the macro design view page.

    Also a good thing to do is to put in a line underneath the 'SetWarnings Off' line for hourglass if other people will be using the database. Obviously you would then need to turn the hourgass off again before you turn the SetWarnings back on!

  6. #6
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    You're welcome!
    Have a nice day!

Posting Permissions

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