473,382 Members | 1,717 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Using a .bat file to open an Access Database

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
9 42162
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

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

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
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

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
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

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
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

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

Jan 30 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Mark | last post by:
Not sure this is the right place for this questions, but here goes: I get an error message when deleting an table from a Access database. The code is as follows and the error message is after...
1
by: bailee220 | last post by:
I have included the following code to open an Access database form from within an exsisting Access database. But when I run the code, it appears that it opens the database because in windows...
0
by: Bill Thom | last post by:
I have a Microsoft Access 2000 (9.0.4402 SR-1) database that I am attempting to launch from a hyperlink using Internet Explorer (Version 6.0.2800.1106). If I attempt to launch the database from...
0
by: Dodong | last post by:
Hi, i am a new vb6 programmer. I would like to know the vb6 code to read excel file and save it to access database. I am using ADO.
5
by: Dave | last post by:
I need to filter an Access 2000 result set in ASP 30 using the ADO recordset.filter. I build the filter in pieces. The first clause of the filter is this... WHERE word LIKE 'S%' ... to...
1
by: mitucse | last post by:
Hi I am in touble to connect my html file with access database. please reply me if anybody can send me the connection code. thank you
2
by: shireen Eason | last post by:
How to create a text output file from access database?
2
by: George Yar | last post by:
Re: How to show changes in open Access 2003 Table in VB I have a form to add a new record to my Access Database table. This is a code: Private Sub btnAdd_Click() Dim dbExpenses As...
0
by: Brian Connelly | last post by:
I am writing a "Form" program that will check a some data received from a LDAP connection against an Access database. What I would like to do is have the user to manually click a button and update...
0
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...
0
isladogs
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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$) { } ...
0
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...
0
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...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.