AutoExec

S

SirPoonga

AutoExec is just a macro access can run on startup, right?

So if I wanted a function to run on startup I would have to make a
function and call it from within the AutoExec macro?
 
A

Andi Mayer

AutoExec is just a macro access can run on startup, right?

So if I wanted a function to run on startup I would have to make a
function and call it from within the AutoExec macro?

right
 
B

Brian

SirPoonga said:
AutoExec is just a macro access can run on startup, right?

So if I wanted a function to run on startup I would have to make a
function and call it from within the AutoExec macro?

Or, specify a startup form and put your startup code in it's open event. If
you don't want the form to actually appear, have the open event cancel
itself.
 
S

SirPoonga

Ok, to go along with this I want to read in the command line arguments.
Actually, I want to send some.

Can I make a shortcut to the mdb and add commandline args? How would I
do that, I tried several things but no command line args worked.

I created an autoexec macro that runs an autoexec function (creative,
huh?). That function for now just does a msgbox command.

I eventually wnat to startup a different form based upon the command
line argument. I want to make a sales shortcut and an engineering
shortcut.
 
B

Brian

SirPoonga said:
Ok, to go along with this I want to read in the command line arguments.
Actually, I want to send some.

Can I make a shortcut to the mdb and add commandline args? How would I
do that, I tried several things but no command line args worked.

I created an autoexec macro that runs an autoexec function (creative,
huh?). That function for now just does a msgbox command.

I eventually wnat to startup a different form based upon the command
line argument. I want to make a sales shortcut and an engineering
shortcut.

To pick up command line arguments you need to use the Command function.
Look it up in help: there is an example of doing exactly what you want (at
least, in Access 2002 help there is).
 
A

Arvin Meyer

You actually have 3 choices of how to do your task:

1. /cmd the last switch in the startup options will allow you run a VBA
startup command (such as opening a form)
2. A macro named AutoExec which will allow several commands or even call a
VBA function which can run as many as you like.
3. A startup form (which can be hidden ... set visible to false in the Load
event) which can run code, call code, and store variables for later use.
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access Downloads
http://www.datastrat.com
http://www.mvps.org/access
 
S

SirPoonga

I am using access 2k. If you noticed my post I said "msgbox command"
I know about the command. My main concern is sending something to
access via a short cut. I created a shortcut witht he follow porperty.
"C:\mydb.mdb" \cmd "option1"
Command return an empty string if I start this shortcut.
 
D

Douglas J. Steele

In order to recognize parameters being passed, shortcuts must include the
name of the executable as well:

"C:\Program Files\Microsoft Office\Office10\msaccess.exe" "C:\mydb.mdb" \cmd
"option1"
 
B

Brian

SirPoonga said:
I am using access 2k. If you noticed my post I said "msgbox command"
I know about the command. My main concern is sending something to
access via a short cut. I created a shortcut witht he follow porperty.
"C:\mydb.mdb" \cmd "option1"
Command return an empty string if I start this shortcut.

In addition to Doug's comment, please note that the /cmd option uses a
FORWARD slash, not a BACK slash. Here is the example from Access 2002 help:

Example

The following example shows how to launch Microsoft Access with a
command-line argument, and then shows how to return the value of this
argument by using the Command function.

To test this example, click the Windows Start button and click Run. Type the
following code in the Run dialog box on a single line. (You must surround
the parts of the command line information in quotation marks).

"C:\Program Files\Microsoft Office\Office10\Msaccess.exe" _
"C:\Program Files\Microsoft Office\Office10\Samples\Northwind.mdb" /cmd
"Orders"

Next, create a new module in the Northwind sample database and add the
following Sub procedure:

Public Sub CheckCommandLine()

' Check the value returned by Command function and display
' the appropriate form.
If Command = "Orders" Then
DoCmd.OpenForm "Orders"
ElseIf Command = "Employees" Then
DoCmd.OpenForm "Employees"
Else
Exit Sub
End If

End Sub

When you call this procedure, Microsoft Access will open the Orders form.
You can create an AutoExec macro to call this procedure automatically when
the database is opened.
 

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