Solved

Access 2007 Macro hangs with SetWarnings

Posted on 2011-03-06
6
1,020 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 

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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

636 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