Hi Roy,
As Andrew mentioned you will need to use the
Application.CurrentProject.OpenConnection command to accomplish this from a
startup form.
However, the trick is that your ADP needs to be in a disconnected state upon
startup for this to work. Otherwise, your code never gets a chance to run.
To place your ADP in a disconnected state, always run the following line of
code just before a user closes your application:
Application.CurrentProject.OpenConnection ""
This code clears your connection properties and allows for your startup code
to reset the connection the next time the ADP is opened. What I recommend
is to run this code from the close event of a hidden form, so that it is
always run as the last command before the app is closed, regardless of how
the app is closed. I normally just hide the startup form and then the code
is run from the close event of the startup form.
The only time this doesn't work is when the ADP is closed due to an
unexpected event such as a power failure.
Hope this helps,
Brian M. Sockey