Solved

Ho do I use macro to force close Access 2007?

Posted on 2011-03-22
3
340 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

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 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…
Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
Familiarize people with the process of utilizing SQL Server views 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 Access…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

733 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