I need to be able to write a macro in one database that will run a macro in another database.
The current action I am trying to use is RunApp. I have a similar macro for excel and the command line is EXCEL.exe I:\OTI\Mi_Accts\Cost_Provisions\Mirror_Tables\MACR O_HOLDER.xls. I thought it would be as simple as changing it to access.exe I:\OTI\Mi_Accts\Cost_Provisions\Mirror_Tables\Mast er\OA Provisions by Month.mdb but it did not work.
Is it possible?
7 3710 NeoPa 32,556
Expert Mod 16PB
Not really possible the way you describe it (or maybe it is but I know little about archaic parts of Access like the macros).
I know it is possible, however, to have a database set up so that it will run a macro (autoexec) every time it is opened.
I need to be able to write a macro in one database that will run a macro in another database.
The current action I am trying to use is RunApp. I have a similar macro for excel and the command line is EXCEL.exe I:\OTI\Mi_Accts\Cost_Provisions\Mirror_Tables\MACR O_HOLDER.xls. I thought it would be as simple as changing it to access.exe I:\OTI\Mi_Accts\Cost_Provisions\Mirror_Tables\Mast er\OA Provisions by Month.mdb but it did not work.
Is it possible?
There is absolutely no need to write a Macro in the Current Database to Run a Macro in an External Access Database when you can Run it directly with a little Automation code and some trickery. The following code will Run the Macro named External Macro in the RunMacro.mdb Database in the C:\Test\ Directory. Make an necessary adjustments to produce your desired results. Any questions, feel free to ask: - Dim strDBPath As String, strMacroName As String
-
-
strDBPath = "C:\Test\RunMacro.mdb"
-
strMacroName = "External Macro"
-
-
Dim appAccess As Access.Application
-
-
'Create a New Instance of Access
-
Set appAccess = CreateObject("Access.Application")
-
-
'Open the External Database in Access Window
-
appAccess.OpenCurrentDatabase strDBPath
-
-
'Run the Macro
-
appAccess.DoCmd.RunMacro strMacroName
-
-
'little house cleaning
-
appAccess.CloseCurrentDatabase
-
Set appAccess = Nothing
Hi there,
I was looking at doing exactly the same thing, this is great, thanks a mill!
I've just one additional query, we have to use a username and password to logon onto the database. Do you know a way of overriding this or the code to enter a static username and password?
Thanks in advance.....
There is absolutely no need to write a Macro in the Current Database to Run a Macro in an External Access Database when you can Run it directly with a little Automation code and some trickery. The following code will Run the Macro named External Macro in the RunMacro.mdb Database in the C:\Test\ Directory. Make an necessary adjustments to produce your desired results. Any questions, feel free to ask: - Dim strDBPath As String, strMacroName As String
-
-
strDBPath = "C:\Test\RunMacro.mdb"
-
strMacroName = "External Macro"
-
-
Dim appAccess As Access.Application
-
-
'Create a New Instance of Access
-
Set appAccess = CreateObject("Access.Application")
-
-
'Open the External Database in Access Window
-
appAccess.OpenCurrentDatabase strDBPath
-
-
'Run the Macro
-
appAccess.DoCmd.RunMacro strMacroName
-
-
'little house cleaning
-
appAccess.CloseCurrentDatabase
-
Set appAccess = Nothing
Hi there,
I was looking at doing exactly the same thing, this is great, thanks a mill!
I've just one additional query, we have to use a username and password to logon onto the database. Do you know a way of overriding this or the code to enter a static username and password?
Thanks in advance.....
If the Database itself is Password Protected, you can simply supply the Password in the 3rd Argument of the OpenCurrentDatabase() Method. You may also want to specify the Optional 2nd Argument and Open the DB Exclusively for your operation.
NeoPa 32,556
Expert Mod 16PB
I'm pretty sure it's the Security (.MDW) name and password he's talking about. A whole different question really. This needs to be posted separately, in its own thread.
I'm pretty sure it's the Security (.MDW) name and password he's talking about. A whole different question really. This needs to be posted separately, in its own thread.
Thanks NeoPa, I didn't even realize that it was a different Poster. What in the world would I ever do without your keen oversight? (LOL).
NeoPa 32,556
Expert Mod 16PB
No probs my friend. I suppose I should really have split the thread but was running quite late yesterday. He got away with it this time huh ;)
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Ed Mana |
last post by:
I have an Access app that I need to automate in 2 ways:
1. I need to have the app open and print a specific report once each
day at a specific time.
2. I need to have the app take the same...
|
by: Chris |
last post by:
Hello all. I have a database that I use to send email updates to
people. Everything is working fine, but one suggestion I keep getting
is to add a link to the automatic emails that will open up the...
|
by: mvivar |
last post by:
Hi everybody:
This will be not easy to explain as my mother language is not english,
so my apologies in advance if it sounds confusing.
We have a database access 97 wich controls time of...
|
by: Roman Mashak |
last post by:
Hello, All!
I'm trying to set up macro:
....
int main(int argc, char *argv, char *envp)
{
....
if ( argc > 1 ) {
if ( strcmp(argv, "-d") == 0 ) {
|
by: Pat_RI |
last post by:
I am trying to call a macro using a command file by using Windows
Scheduler. I am able to run the command file and the macro runs
without issue if I doubleclick on the *.cmd file. When I try...
|
by: John Baker |
last post by:
Hi;;
Can someone give me the name for the first macro executed when an Access application is
opened? Its is AutoExec; AutoOpen; Open or something else?
For some reason I cant find that...
|
by: tonytony24 |
last post by:
Hi All:
I was wondering if there's a simple way to call a MS Access Module
through either
Command Prompt
MS Script
any other way...
Thanks for the response.
|
by: sumGirl |
last post by:
Is it possible to run an access query from the scheduler? I need to
update a table in the middle of the night, and so I would like to set
up a job on a machine thats on all night so I dont have to...
|
by: mscurto |
last post by:
Is there a way to set up access to open and run a query in a particular
database at a particular time each day? This would be run from a
Windows 2000 desktop.
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |