Solved

Access 2007 Macro hangs with SetWarnings

Posted on 2011-03-06
6
1,006 Views
Last Modified: 2012-06-21
Created a Macro in Access 2007 to run a query.  The query runs fine, database is trusted, the confrim action queries is off.  When I setwarnings to No or Yes before the query, the macro hangs.  When I remove the setwarnings, everything runs fine again, but I don't want the confirmation prompts.  I would like to run this macro as a scheduled task so I do not want any prompts.

Suggestions?
0
Comment
Question by:mjwcai
  • 3
  • 2
6 Comments
 

Author Comment

by:mjwcai
ID: 35047570
I should also add that when I single step through the Macro and use Setwarning, it will go to the next step in the macro, but then hangs on the query step.  Removing the setwarnings and then using single steps..., the macro completes fine.
0
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 250 total points
ID: 35047663
Consider using VBA code to run this action query like so:

Public Function mRunMyQuery

    CurrentDB.Execute "YourActionQueryName", dbFailOnError

End Function

This avoids the prompts - and will generate a trappable error if the action query should fail for some reason.  Using SetWarnings False is very dangerous in general.

mx

 
0
 
LVL 21

Assisted Solution

by:Boyd (HiTechCoach) Trimmell, Microsoft Access MVP
Boyd (HiTechCoach) Trimmell, Microsoft Access MVP earned 250 total points
ID: 35047670
Assuming you are are not using a Web database:

If it were me I would  use VBA so that you can have error handling id needed.

I would use this VBA code command: CurrentDB.Execute  
Using this command you do not need to set the warning to false.  I use it in scheduled databases with great success.

It is possible to put this VBA code in a function and call it from your Macro.



0
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

 

Author Comment

by:mjwcai
ID: 35047782
How do I get a VBA to work in a scheduled task?
0
 
LVL 21
ID: 35048039
As a scheduled task I would assume you would be using the Windows Task Scheduler.

See:
How to Start Access by Using the Windows Schedule Service

Alternative:

Scheduler Utility




0
 

Author Comment

by:mjwcai
ID: 35048292
I guess my question was how do I get the VBA into the macro so I can run as a scheduled task - I have never used VBA before - but I figured it out and got it working
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

713 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