?
Solved

Ho do I use macro to force close Access 2007?

Posted on 2011-03-22
3
Medium Priority
?
349 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 2000 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Suggested Courses

777 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