Results 1 to 10 of 10
  1. #1
    gstylianou is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Dec 2013
    Posts
    167

    Problem with access messages on queries

    Good evening to all,




    Guys I'm stuck on an issue that I am sure for many of you it may seem slightly " deaf " but unfortunately either my mind is stuck or....i don't know whats happened.


    Well , I have written the below vba code so that, firstly to run the first without any messages and then the second one as well as without the access messages.


    The problem is while I've written correct the code ( I think ) so to run the queries messages without the access messages, however the messages still displayed and indeed the first query displayed normal..


    Following, is the code and i will appreciated if i would have your lights again

    Private Sub LabelNewCustomers_Click()

    DoCmd.SetWarnings False
    DoCmd.OpenQuery "qryTransferCmrDetails2", acViewNormal
    DoCmd.SetWarnings True

    DoCmd.RunCommand acCmdRefresh

    DoCmd.SetWarnings False
    DoCmd.OpenQuery "qryTransferData2", acViewNormal
    DoCmd.SetWarnings True
    DoCmd.OpenForm "fTempTable", acNormal, , , , acHidden

    Dim stDocName As String
    Dim stLinkCriteria As String
    stDocName = "frmCustomerDetails"
    stLinkCriteria = "[Customer No]=" & Me![Customer No]
    DoCmd.OpenForm stDocName, , , stLinkCriteria
    DoCmd.GoToRecord , , acNewRec

    End Sub


    Thanks in advanced

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    FYIs
    1st....DoCmd.OpenQuery "qryTransferCmrDetails2"
    the acViewNormal is not needed.

    2.
    The: DoCmd.SetWarnings False
    is only needed once at the beginning of the process
    and a single DoCmd.SetWarnings True at the end. No need to keep turning them on and off every step.

    3. A good custom is to use query names that show the action of it... qryTransferData2 ..the qry tells you nothing of the query in the code..
    better would be quTransferData2 for update, qsTransferData2 for select, qm for make, qa for append, etc.

    Now the above is only FYI, but I still did not understand your question above. What exactly is the problem?



  3. #3
    gstylianou is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Dec 2013
    Posts
    167
    Hi my friend ramman,

    Thanks for the information's. The problem is: I have two queries which i wanted to run without to give any access messages and of course without to open as usual mode (like a table). In my case when i'm trying to do that with the attached code i didn't take any messages but the first query appear normally (as a table mode..) and of course i don't want it..

    Any idea?

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Is the first query just a SELECT query that perhaps the other 2 depend on? If so, you don't need to open it at all. Access will do that internally.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    As Paul says, SELECT query objects don't have to be opened.

    If the query objects are action queries (UPDATE, INSERT, DELETE) can use:

    CurrentDb.Execute "qryTransferCmrDetails2"

    And the DoCmd.SetWarnings lines are then not needed at all and no warnings will pop up with the Execute method.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Quote Originally Posted by June7 View Post
    can use:

    CurrentDb.Execute "qryTransferCmrDetails2"

    And the DoCmd.SetWarnings lines are then not needed at all and no warnings will pop up with the Execute method.
    Not if there are form references in the query.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Good point.

    Since I don't use dynamic parameters in queries, not an issue I deal with.

    I also use an SQL statement instead of referencing a query object.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  8. #8
    Geo21 is offline Novice
    Windows 8 Access 2013
    Join Date
    May 2014
    Posts
    20

    Problem with access messages on queries

    What kind of messages do you get?

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    The messages are warnings that edits to table will occur - such as insert, delete, update records. These are not error messages but are nonetheless often not appreciated.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  10. #10
    Geo21 is offline Novice
    Windows 8 Access 2013
    Join Date
    May 2014
    Posts
    20

    Problem with access messages on queries

    But is he getting these warnings, or error warnings?

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

Similar Threads

  1. Suppressing Access messages
    By Reaper in forum Forms
    Replies: 1
    Last Post: 11-06-2011, 04:02 PM
  2. Problem with Access Queries\Reports
    By Crysis3nt in forum Access
    Replies: 1
    Last Post: 09-09-2010, 02:26 AM
  3. Custom messages to Access' default error messages.
    By evander in forum Programming
    Replies: 1
    Last Post: 06-26-2010, 02:06 AM
  4. Replies: 3
    Last Post: 10-15-2009, 12:24 PM
  5. SENDING EMAIL MESSAGES DIRECTLY FROM ACCESS
    By Frenchos in forum Access
    Replies: 0
    Last Post: 07-20-2007, 12:51 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