By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,998 Members | 2,871 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,998 IT Pros & Developers. It's quick & easy.

How to run a ACCESS VBA form in a bat file

P: 6
I have a VBA form created in MS ACCESS to extract data from multiple Oracle tables. Now I need to run it once a day by Window scheduler. How do I do it?
Jan 9 '07 #1
Share this Question
Share on Google+
11 Replies


NeoPa
Expert Mod 15k+
P: 31,492
1. Create a form that automatically runs your process then closes the database when done.
2. Using Tools / Startup, set that form to open automatically on opening the database.
3. Add to your batch file the Access command to open your database. This can be done simply as the name of the database.

Unless you are using Win98 or WinME I recommend you use a .Cmd file rather than a .Bat one.
Jan 10 '07 #2

P: 6
1. Create a form that automatically runs your process then closes the database when done.
2. Using Tools / Startup, set that form to open automatically on opening the database.
3. Add to your batch file the Access command to open your database. This can be done simply as the name of the database.

Unless you are using Win98 or WinME I recommend you use a .Cmd file rather than a .Bat one.
Thanks for your reply. Since this is my first VBA form I have more questions to ask:
1. To close the database means to code a statement in the VBA to close the mdb or click on x to close the form? Also, how do you automatically click the start button to run without human intervention?
2. Does it create a .ldb file? or something else?

GFEDCBA
Jan 10 '07 #3

NeoPa
Expert Mod 15k+
P: 31,492
1a. To close the database means to code a statement in the VBA to close the mdb.
1b. You don't trigger the code on a button. You use something like the OnOpen event instead.
2. The file to use could happily be a .MDB file - an ordinary Access database.
Jan 10 '07 #4

P: 6
1a. To close the database means to code a statement in the VBA to close the mdb.
1b. You don't trigger the code on a button. You use something like the OnOpen event instead.
2. The file to use could happily be a .MDB file - an ordinary Access database.
Thanks again.
GFEDCBA
Jan 10 '07 #5

NeoPa
Expert Mod 15k+
P: 31,492
No Problem - glad to help.
Jan 11 '07 #6

P: 6
No Problem - glad to help.
I followed your suggestion and automated the VBA scripts already. Now, I like to know when you need to make the change to the original scripts, how do you open the codes in mdb file without running the form?

GFEDCBA
Feb 13 '07 #7

NeoPa
Expert Mod 15k+
P: 31,492
  1. Open database in Access.
  2. Alt-F11 to open VBA window.
  3. Ctrl-R to view Project Explorer window.
  4. Select object that you want to see the related code for.
  5. Double-click on it or F7 the selected item to open the related code window.
Feb 13 '07 #8

P: 6
  1. Open database in Access.
  2. Alt-F11 to open VBA window.
  3. Ctrl-R to view Project Explorer window.
  4. Select object that you want to see the related code for.
  5. Double-click on it or F7 the selected item to open the related code window.
The problem I have is when you tried to open it, it starts to run. You don't even have the chance to do Alt-F11 to open VBA window.

GFEDCBA
Feb 13 '07 #9

NeoPa
Expert Mod 15k+
P: 31,492
This is controlled by the designer of the database, but unless he's locked it down very tightly, the bypass key (SHIFT) key, held down while opening the database, should bypass the normal running of the project.
Feb 13 '07 #10

P: 6
This is controlled by the designer of the database, but unless he's locked it down very tightly, the bypass key (SHIFT) key, held down while opening the database, should bypass the normal running of the project.
Thank you for your answer. It does work.
I still have problems on this program:
1. the program seems like not drop the records on the output table and re-extract the new records from multiple input tables. I suspect there is a security issue on dropping the records.
2. Why ldb file presents all the times? The table is read frequently by more than one programs.

GFEDCBA
Feb 13 '07 #11

NeoPa
Expert Mod 15k+
P: 31,492
1. the program seems like not drop the records on the output table and re-extract the new records from multiple input tables. I suspect there is a security issue on dropping the records.
Drop records :confused: No idea what you mean.
2. Why ldb file presents all the times? The table is read frequently by more than one programs.
An LDB file is where Access stores it's locking and access status. Whenever an MDB is open by at least one connection an LDB file exists.
Feb 13 '07 #12

Post your reply

Sign in to post your reply or Sign up for a free account.