Solved

Ho do I use macro to force close Access 2007?

Posted on 2011-03-22
3
348 Views
Last Modified: 2012-08-13
I have a macro that runs from one acces database to export a table to a different database.  The purpose is to update the table with current daily data.  The user of the database to be updated often forgets to close the database to be updated or is runing a query or macro in it.  This causes my database with the auto macro to error out because the database/table to be updated is being used by a different user.

QUESTION:  Is there a way end the macro and force close the database when an error dialogue box is open?  My desired end result would be to stop the macro from trying to update the external database and close the current database out.  The reason is that a separate database macro runs at a later time.
0
Comment
Question by:wmb02
[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
  • 2
3 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 35189872
modify your "auto macro" to run a function that will export a table to the other database.
In the function, you can trap the error and likewise exit (quit) the application.
0
 

Author Comment

by:wmb02
ID: 35206482
capicorn1:
Would you please provide me an example of a sample "auto macro" to run a function that you described.
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
ID: 35206551
first create a function in a regular VBA module

function myexport()
on error goto err_handler

'your codes to export the table and etc...


err_handler:
  if err.number=<the error number you are getting>
     err.clear
     docmd.quit
    else
      'other errors coding
  end if

end function

* save module as modExport or any name you want except the name of any function

now in your AUTOEXEC macro add an action
RunCode


Function Name myexport()


0

Featured Post

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
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.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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.

707 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