Solved

How to determine if a query has executed successfully?

Posted on 2003-12-08
5
625 Views
Last Modified: 2011-08-18
I have a macro that runs three action queries one after the other (OpenQuery). I want to execute the 2nd and 3rd query only if the first action query (update) was executed successfully (No violations etc...). How can I do it? As of now, Access continues to execute the remaining queries no matter whether the first query was successfully executed or not. How can I check whether the first query was successfully executed?
Thanks
0
Comment
Question by:Sankar030999
  • 2
  • 2
5 Comments
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 9897324
what code are you currently using to do this?

AW
0
 

Author Comment

by:Sankar030999
ID: 9897339
I am not using any code. I am just doing it from within Access. I created the queries within Access and create a Macro in Access to run all the queries (OpenQuery) one after the other.
Sankar
0
 
LVL 32

Accepted Solution

by:
jadedata earned 500 total points
ID: 9897356
Hey Sankar!

  If you switch to using VBA code to perform this:
 
  You can use the command
  db.execute "QueryName", dbfailonerror

  1.  If a query fails, a trappable error is raised.
  2.  If you want to know if RECORD were affected by the query (like how many updates were performed)
     you can ask Access for

   x = db.recordsaffected
   if x > 0 then
     'do this
   else
     'stop here
   endif

See Access help for examples of the execute method and recordsaffected properties

These are DAO object children that require the inclusion of the MS DAO 3.6 object library.
regards
Jack
0
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 9897560
"I created the queries within Access and create a Macro in Access to run all the queries (OpenQuery) one after the other. " this is the main reason for your problem.

As Jadedata has stated, if you want to check on the status of the first query before executing the others, you MUST use VBA code.


This is NOT a job to be carried out with a MACRO - in fact, there is NO JOB that should be carried out with a MACRO.  Microsoft STRONGLY advises AGAINST using Macros - they are supported almost purely for backward compatability with previous versions of Access, and should NOT be used for new databases.

AW
0
 
LVL 32

Expert Comment

by:jadedata
ID: 9897597
Just say "No" to Macros!!
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question