Open and close access file

M

Marco

Hello.

how can I open and close an access file from another access file.

I want to execute at a specific time a access macro to open a third access
file and after 1 minute to close.

In this way I can compact everynight a bacik-end of mine.

Thanks,
Marco
 
J

John Keith

Instead of having one DB call another... try this:

In "Scheduled tasks" add a task that calls the main access program with a
parm for the DB and a /x parm to run a named macro...

"C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.EXE"
"C:\path\BackEndDB.mdb" /x autoexec2

In the BackEndDB create a VB Module with these functions:

Function Compact_On()
Application.SetOption "Auto Compact", True
End Function
Function Compact_Off()
Application.SetOption "Auto Compact", False
End Function

Create a macro named "autoexec2" in your back_end DB that you want to
compress at the scheduled times.
For the action use "RunCode" and point to the "Compact_On()" function.
And a 2nd Action to Quit the application.

Create another macro named "autoexec" and RunCode pointing to the
"Compact_Off()" function; so that when you open the DB manually it will not
always be set to compact on close.
 
M

Marco

thanks my friend.

I'll try.





John Keith said:
Instead of having one DB call another... try this:

In "Scheduled tasks" add a task that calls the main access program with a
parm for the DB and a /x parm to run a named macro...

"C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.EXE"
"C:\path\BackEndDB.mdb" /x autoexec2

In the BackEndDB create a VB Module with these functions:

Function Compact_On()
Application.SetOption "Auto Compact", True
End Function
Function Compact_Off()
Application.SetOption "Auto Compact", False
End Function

Create a macro named "autoexec2" in your back_end DB that you want to
compress at the scheduled times.
For the action use "RunCode" and point to the "Compact_On()" function.
And a 2nd Action to Quit the application.

Create another macro named "autoexec" and RunCode pointing to the
"Compact_Off()" function; so that when you open the DB manually it will not
always be set to compact on close.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top