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

Using a .bat file to open an Access Database

P: n/a
How would I do this ... I want to set the Windows Scheduler to run the
..bat file which will open an access database at like 2 in the AM. What
code do I need in the .bat file.

Jan 22 '07 #1
Share this Question
Share on Google+
9 Replies


P: n/a
Matt wrote:
How would I do this ... I want to set the Windows Scheduler to run the
.bat file which will open an access database at like 2 in the AM.
What code do I need in the .bat file.
Is there a reason you need to use a BAT file? You should be able to just
use the command line that will directly open the MDB file. Below is an
example of a command that I execute in the scheduler every day.
"C:\Program Files\access97\Microsoft Office\Office\MSACCESS.EXE"
"C:\Documents and Settings\rbrandt\Desktop\SiceSerNumFix.mdb"

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
Jan 22 '07 #2

P: n/a

Rick Brandt wrote:
Matt wrote:
How would I do this ... I want to set the Windows Scheduler to run the
.bat file which will open an access database at like 2 in the AM.
What code do I need in the .bat file.

Is there a reason you need to use a BAT file? You should be able to just
use the command line that will directly open the MDB file. Below is an
example of a command that I execute in the scheduler every day.
"C:\Program Files\access97\Microsoft Office\Office\MSACCESS.EXE"
"C:\Documents and Settings\rbrandt\Desktop\SiceSerNumFix.mdb"

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
Can I schedule this?
How would I do that?

Jan 22 '07 #3

P: n/a

Matt wrote:
Rick Brandt wrote:
Matt wrote:
How would I do this ... I want to set the Windows Scheduler to run the
.bat file which will open an access database at like 2 in the AM.
What code do I need in the .bat file.
Is there a reason you need to use a BAT file? You should be able to just
use the command line that will directly open the MDB file. Below is an
example of a command that I execute in the scheduler every day.
"C:\Program Files\access97\Microsoft Office\Office\MSACCESS.EXE"
"C:\Documents and Settings\rbrandt\Desktop\SiceSerNumFix.mdb"

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com

Can I schedule this?
How would I do that?

My fault ... I did not see that you schedule it every day.

Thanks for the tip!!
How can I open access straight to the default form and bypass the
"Cancel ... Open" dialog so that I can run some code based on the
default form?

Jan 22 '07 #4

P: n/a
Matt wrote:
Rick Brandt wrote:
>Matt wrote:
>>How would I do this ... I want to set the Windows Scheduler to run
the .bat file which will open an access database at like 2 in the
AM. What code do I need in the .bat file.

Is there a reason you need to use a BAT file? You should be able to
just use the command line that will directly open the MDB file.
Below is an example of a command that I execute in the scheduler
every day.
"C:\Program Files\access97\Microsoft Office\Office\MSACCESS.EXE"
"C:\Documents and Settings\rbrandt\Desktop\SiceSerNumFix.mdb"

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com

Can I schedule this?
How would I do that?
Don't use the "Add Scheduled Task" wizard. That is lame anyway. Just
use...

File
New
Scheduled Task

....then open the property sheet for the new task. In there you will see a
box labeled "Run". You just enter the command in that box.

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
Jan 22 '07 #5

P: n/a

Rick Brandt wrote:
Matt wrote:
Rick Brandt wrote:
Matt wrote:
How would I do this ... I want to set the Windows Scheduler to run
the .bat file which will open an access database at like 2 in the
AM. What code do I need in the .bat file.

Is there a reason you need to use a BAT file? You should be able to
just use the command line that will directly open the MDB file.
Below is an example of a command that I execute in the scheduler
every day.
"C:\Program Files\access97\Microsoft Office\Office\MSACCESS.EXE"
"C:\Documents and Settings\rbrandt\Desktop\SiceSerNumFix.mdb"

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
Can I schedule this?
How would I do that?

Don't use the "Add Scheduled Task" wizard. That is lame anyway. Just
use...

File
New
Scheduled Task

...then open the property sheet for the new task. In there you will see a
box labeled "Run". You just enter the command in that box.

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com

Thanks for the help so far Rick.

When I do this, I get the following error:
0x80070005 Acces is Denied
You do not have permission to perform the requested operation

Is this a windows permission issue, more than likely restricted by my
employer?

Jan 22 '07 #6

P: n/a
You can use a bat file..and go:

start "c:\path name to file\mydb.mdb"

You should ensure that the mdb starts...runs whatever...and the shuts down.
You need to test this.

Did I say you need to test this?

However, in place of a bat file, you best use a windows script.

Just paste the folwling into a standard notepad.txt

dim accessApp

msgbox "Click ok to run batch job",64

set accessApp = createObject("Access.Application")

accessApp.OpenCurrentDataBase("C:\Documents and Settings\Albert\My
Documents\Access\ScriptExample\MultiSelect.mdb")

accessApp.Run "TimeUpDate"

accessApp.Quit

set accessApp = nothing

msgbox "Job complete", 64

Now, save the file..and then re-name the .txt extension to .vbs. note
how the icon for the file changes. Congratulation...you just written your
first
windows script.

The above script when clicked on will now run. It actually executes a sub
call "TimeUpDate" that exists in a standard code module...and then now how
it shuts down (quits).

If you going to put the above script into the scheduler...then of course
remove the msgbox commands.....
--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pl*****************@msn.com

Jan 23 '07 #7

P: n/a

Albert D. Kallal wrote:
You can use a bat file..and go:

start "c:\path name to file\mydb.mdb"

You should ensure that the mdb starts...runs whatever...and the shuts down.
You need to test this.

Did I say you need to test this?

However, in place of a bat file, you best use a windows script.

Just paste the folwling into a standard notepad.txt

dim accessApp

msgbox "Click ok to run batch job",64

set accessApp = createObject("Access.Application")

accessApp.OpenCurrentDataBase("C:\Documents and Settings\Albert\My
Documents\Access\ScriptExample\MultiSelect.mdb")

accessApp.Run "TimeUpDate"

accessApp.Quit

set accessApp = nothing

msgbox "Job complete", 64

Now, save the file..and then re-name the .txt extension to .vbs. note
how the icon for the file changes. Congratulation...you just written your
first
windows script.

The above script when clicked on will now run. It actually executes a sub
call "TimeUpDate" that exists in a standard code module...and then now how
it shuts down (quits).

If you going to put the above script into the scheduler...then of course
remove the msgbox commands.....
--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pl*****************@msn.com


Thanks for the help!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!

Jan 23 '07 #8

P: n/a
Matt wrote:
Thanks for the help so far Rick.

When I do this, I get the following error:
0x80070005 Acces is Denied
You do not have permission to perform the requested operation

Is this a windows permission issue, more than likely restricted by my
employer?
I believe scheduled tasks run with the permissions of "SYSTEM" in most Window OS's (not
sure on newer ones). "SYSTEM" has limited permissions - I don't believe it even has
ability to use a network. You can/should research this to verify the exact details.

The Task Scheduler entry should have a place where you can indicate an account that you
want the scheduled task to "run as". Most likely this will solve this error.

Did you find the error in one of the Event Logs? That would be the place to see the
results of the scheduled task.

--
'---------------
'John Mishefske
'---------------
Jan 26 '07 #9

P: n/a

I ended up putting a password in the scheduler and it was smooth
sailing.

Jan 30 '07 #10

This discussion thread is closed

Replies have been disabled for this discussion.