Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Command Line Macro no AutoExec

Status
Not open for further replies.

djj55

Programmer
Feb 6, 2006
1,761
US
Hello, Access 2002
I want to execute a macro from a batch file which I can do. The problem is I want the AutoExec not to run, or determine that the macro is running.

I can program statements to jump out of the AutoExec but I do not know how to tell that the macro is running.

Thanks
djj

 
Hi djj,

How are you running the Macro from a batch file.

Can you post a sample here.

Without the sample, my best guess would be to pass a parameter when you run the Macro. Then, in the AutoExec, you would need to see if the passed field was used and if so, check to see if the Macro was run and is still running.

An other idea might be to eliminate the AutoExex and use a Startup form and/or code to check the parameters.

Hope this helps,
Hap...

Access Developer [pc] Access based Accounting Solutions - with free source code
Access Consultants forum
 
Hello Hap,
Thank you for the reply.
Code:
"C:\Program Files\Microsoft Office\Office10\MSAccess.exe" "W:\Database\AccessDBs\test.mdb" /x "ACCOUNTWork"
Note names changed per company policy.

When this executes the AutoExec macro runs before the AccountWork macro. Given I did not create the database I hesitate to change the startup (also we are starting to reprogram all our Access databases to VB.NET with new a SQL back-end).

That said where can I find information on passing parameters from a batch file? I have tried to search for command line code but have been unable to find a good source.

Thanks again,
djj
 
Hi,

Here are all the available commands I have docs for:
Note, I just cut and pasted so please excuse the formatting

Use /cmd

Specifies that what follows on the command line is the value that will be returned by the Command function. This option must be the last option on the command line. You can use a semicolon (;) as an alternative to /cmd.

Then, in VBA Code fuse the function X=Command() to return what was passed on the startup command line.

Full List of Options:

Startup command-line options

The following table lists the Microsoft Access command-line options.

Option Effect
database
Opens the specified database. Include a path if necessary. The default path is your My Documents folder.

/excl
Opens the specified database for exclusive access. To open the database for shared access in a multiuser environment, omit this option.

/ro
Opens the specified database for read-only access.

/user user name
Starts Microsoft Access using the specified user name.

/pwd password
Starts Microsoft Access using the specified password.

/profile user profile
Starts Microsoft Access using the options in the specified user profile instead of the standard Windows Registry settings created when you installed Microsoft Access. This replaces the /ini option used in previous versions of Microsoft Access to specify an initialization file. The Microsoft Office 97, Developer Edition, contains tools and information on creating user profiles. For more information, click .

/compact target database
Compacts the database specified before the /compact option and then closes Microsoft Access. If you omit a target database name following the /compact option, the database is compacted to the original database name and folder. To compact to a different name, specify a target database. If you don't include a path in target database, the database is created in your My Documents folder by default.

/repair
Repairs the database specified before the /repair option and then closes Microsoft Access.
/convert target database Converts a database in an earlier version (1.x or 2.0) to a Microsoft Access 95 database with a new name and then closes Microsoft Access. Specify the source database before the /convert option.

/x macro
Starts Microsoft Access and runs the specified macro. Another way to run a macro when you open a database is to use an AutoExec macro.

/cmd
Specifies that what follows on the command line is the value that will be returned by the Command function. This option must be the last option on the command line. You can use a semicolon (;) as an alternative to /cmd.For information on the Command function, click .

/nostartup
Starts Microsoft Access without displaying the startup dialog box (the second dialog box you see when you start Microsoft Access).

/wrkgrp workgroup information file
Starts Microsoft Access using the specified workgroup information file.
Notes

·To run a Visual Basic for Applications procedure when you open a database, use the RunCode action in a command-line macro or the AutoExec macro. You can also run a Visual Basic procedure when you open a database by creating a form with a Visual Basic procedure defined for its OnOpen event. Designate this as the startup form by right-clicking the database window, clicking Startup, and then entering that form in the Display Form box.
·To specify a forward slash (/) or semicolon (;) on the command line, type the character twice. For example, to specify the password ;mjs/md on the command line, type ;;mjs//md following the /pwd command-line option.

Good Luck,
Hap...


Access Developer [pc] Access based Accounting Solutions - with free source code
Access Consultants forum
 
Hello Hap,
Sorry the thank you is late. I got off on another tangent and forgot to post.

I have worked with the /cmd command and that seams to be what was needed.

Thanks again
djj
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top