Command LIne access

R

Rich Mogy

I would like to start access from the scheduler. To that end I have created
a bat file that starts access with the /x option. (execute a macro)

My macro has been coded to run a function called update. The function
update calls the procedure that I want to run. Unfortunately it doesn't
seem to find the procedure. I have double checked all spellings.

What it does is start access and goes to the module screen with the first
module highlighted. Unfortunately, my procedure is in the fourth module, as
is the function exercised by the macro.

Any help would be appreciated.
 
6

'69 Camaro

Hi, Rich.
My macro has been coded to run a function called update.

1. Change the name of the function to updateData( ), or something
meaningful. "Update" is a reserved word, and reserved words should never be
used as identifiers (table names, column names, procedure names, variables,
properties, et cetera). Doing so introduces bugs when Access uses the name
for its intended purpose, instead of what the developer wanted to use it
for.

2. Ensure that the updateData( ) function is declared as public, not
private.

3. Ensure that the updateData( ) function and the procedure it calls are
both located in a standard module, not a form's module or a class module.
If the procedure it calls is in the same module, then the procedure can be
declared as either public or private. If the procedure is in another module
besides the one that the updateData( ) function is in, then the procedure
must be declared as public.

4. Ensure that you don't have duplicate names for different things, such as
a procedure with the same name as the module it's located in.

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
Blogs: www.DataDevilDog.BlogSpot.com, www.DatabaseTips.BlogSpot.com
http://www.Access.QBuilt.com/html/expert_contributors2.html for contact
info.
 
A

Arvin Meyer [MVP]

I've built a few applications this way and always use a startup form to call
the code. Doing it that way, I've never had a problem.
 
6

'69 Camaro

Hi, Rich.
When executed from the command line, access opens and the highlight is now
on the module with the procedure instead of the first module in the list,
but still doesn't execute.

When invoking it from the command line, are you specifying which executable
to execute, the path to the file to open, and the macro switch with the name
of the macro, or are you hoping that Windows uses whatever Registry settings
and environment settings by default that you need in this case? The default
Windows settings, unless you manually change them after installing Microsoft
Office, will open Access (the last version previously opened) and the
database file specified if it's in the current directory or in the
Environment PATH setting, unless the full path to the file is specified.
All command line switches will be ignored.

Unless you've manually changed those settings, here's example syntax for
command line execution of C:\Work\MyDB.mdb with the mcrUpdate macro (watch
out for word wrap, as this is all one line):

C:\>"C:\Program Files\Microsoft Office\OFFICE11\MSAccess.exe"
C:\Work\MyDB.mdb /x mcrUpdate

Any path, file name, or command line switch argument which contains illegal
characters (i.e., anything other than alphanumeric and the underscore
character) must be surrounded by double quotes. Really, one should never
use illegal characters when naming anything on a computer to avoid all the
gotchas and bugs this common, but ill-advised, practice produces.

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
Blogs: www.DataDevilDog.BlogSpot.com, www.DatabaseTips.BlogSpot.com
http://www.Access.QBuilt.com/html/expert_contributors2.html for contact
info.
 
D

Dirk Goldgar

In
Rich Mogy said:
I would like to start access from the scheduler. To that end I have
created a bat file that starts access with the /x option. (execute a
macro)
My macro has been coded to run a function called update. The function
update calls the procedure that I want to run. Unfortunately it
doesn't seem to find the procedure. I have double checked all
spellings.
What it does is start access and goes to the module screen with the
first module highlighted. Unfortunately, my procedure is in the
fourth module, as is the function exercised by the macro.

Any help would be appreciated.

What macro action are you executing to run the function?
 
R

Rich Mogy

That did it -- thank you
'69 Camaro said:
Hi, Rich.


When invoking it from the command line, are you specifying which
executable to execute, the path to the file to open, and the macro switch
with the name of the macro, or are you hoping that Windows uses whatever
Registry settings and environment settings by default that you need in
this case? The default Windows settings, unless you manually change them
after installing Microsoft Office, will open Access (the last version
previously opened) and the database file specified if it's in the current
directory or in the Environment PATH setting, unless the full path to the
file is specified. All command line switches will be ignored.

Unless you've manually changed those settings, here's example syntax for
command line execution of C:\Work\MyDB.mdb with the mcrUpdate macro (watch
out for word wrap, as this is all one line):

C:\>"C:\Program Files\Microsoft Office\OFFICE11\MSAccess.exe"
C:\Work\MyDB.mdb /x mcrUpdate

Any path, file name, or command line switch argument which contains
illegal characters (i.e., anything other than alphanumeric and the
underscore character) must be surrounded by double quotes. Really, one
should never use illegal characters when naming anything on a computer to
avoid all the gotchas and bugs this common, but ill-advised, practice
produces.

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
Blogs: www.DataDevilDog.BlogSpot.com, www.DatabaseTips.BlogSpot.com
http://www.Access.QBuilt.com/html/expert_contributors2.html for contact
info.
 
A

Albert D. Kallal

Rich Mogy said:
I would like to start access from the scheduler. To that end I have
created a bat file that starts access with the /x option. (execute a macro)

My macro has been coded to run a function called update. The function
update calls the procedure that I want to run. Unfortunately it doesn't
seem to find the procedure. I have double checked all spellings.

Macros and code modules are COMPLETELY different, and un-related in
ms-access.
When you say macro, you do mean an access macro, and not a code module, or a
sub in a code module..right?

You can use the startup switch to run a macro, and that macro can call code
in a standard module. You can't specify a module, or function name in that
switch....it MUST be a name of an actual access macro you have crated...NOT
code, NOT a function name, NOT a sub name, or can it be a code module name
either.

You have to create an actual macro in the macro tab in ms-access.

And, if you have any startup forms and code etc. that stuff will also run,
and thus you need code to correctly shut down and exit ms-access when you
done. In fact, often for this type of scheduling, I crate a separate mdb
with NO startup forms, and just linked tables to the data file. You can then
run your code, or update processes by the windows scheduler.

I explain in detail here how you can do this here:

Batch processing in ms-access (how to run ms-access as a batch job).
http://www.members.shaw.ca/AlbertKallal/BatchJobs/Index.html
 
R

Rich Mogy

That wasn't possible without a lot more effort, but I did receive a response
that works, so thanks for your effort.
 

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