Display form when opening an .mdb

  • Thread starter Thread starter David Portwood
  • Start date Start date
D

David Portwood

I have a shortcut that associates the user with an .mdw and opens my app.
How can I display the main form of the app automatically from this shortcut?
 
Hi David,

You can specify a startup form either by using the Tools > Startup menu
option, or by creating an Autoexec macro. I prefer the macro method--one of
the few times I will ever use a macro--because each action in the macro
executes in a linear fashion. I often times include other startup
configurations, such as a call to a function to check table links, a call to
another function to ensure record level locking for the first user in
(discussed in my Multiuser App. page), etc. If you try to do all this from
VBA code, using a Startup form, you can get inconsistant results. At least
that has been my experience.

If you have a situation where you want to open a different startup form,
depending on the user, then I would use code to grab the NTUserID. Then I'd
use that result to open the appropriate form. I suppose you could do it by
specifying a different macro (http://support.microsoft.com/?id=209207) in the
target line of each user's shortcut, using the /x macroname option, but
that's going to be a higher maintenance solution. Also, it would require that
the user always use the shortcut to start your application. If they simply
double-clicked on the .mdb file, that would bypass the /x macroname method.


Tom Wickerath
Microsoft Access MVP
https://mvp.support.microsoft.com/profile/Tom
http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________
 
I don't know how to create an Autoexec macro so I'll try using the Startup
option within Access. I hope A2000 has that option. As soon as I deploy my
app (and after another week or so of bows and gracious acceptances of
praise: "Kind of you to say so, Mr. President, but really any genius could
have done it") I'll start nudging my boss in the direction of an upgrade.

Btw, your article concerning performance improvements for a split, multiuser
app was very helpful. Thank you very much.
 
Hi David,
I don't know how to create an Autoexec macro so I'll try using the Startup
option within Access.

There's really nothing special about creating an Autoexec macro
(technically, a macro group), versus any other macro. First, lets clarify the
difference between a macro group and a macro name. A macro group is what you
see in the database window when you click on the macros tab (Access 2003 and
earlier). A macro group can contain one or more named macros within it.

Select the macros group. Click on the New button. A new macro group opens up
in design view. Click on the Save button. Assign the name "Autoexec" (without
the quotes). You've just created your first Autoexec macro (or, more
technically correct, your first Autoexec macro group). However, so far, there
are no assigned actions, so nothing will happen if you run this macro.

Select MsgBox in the Action column. Press the F6 key to toggle to the lower
window. Enter "Hello David!" (again, without the quotes) in the message. Save
the macro. To see it work, close your database and re-open it. You should see
a greeting message. That little test demonstrates how this specially named
macro group can be used to run an Action at database startup. Instead of
MsgBox, you can specify OpenForm as the Action, with the name of the form in
the lower window. You can specify RunCode, with the valid name of a function
in a Public module, if you want to run a function.

I hinted earlier at macro name vs. macro group. When you have a macro open
in design view, you can choose to display an additional column "Macro Name".
The menu option View > Macro Names is used to toggle the display of this
column on and off. You can enter a macro name here. When you run a macro
group, only the first macro name will execute. Processing will stop as soon
as a different macro name is encountered. However, you can certainly specify
a certain macro name to run within a particular macro group. This allows one
to have closely related macros all packaged up within one macro group.

Open the sample Northwind database (Access 2003 and earlier). The macro
group named "Customer Phone List" includes two macros, named "Alpha Buttons"
and "Print". The first three lines include comments only. Similarly, the
Suppliers macro group contains five named macros: Add Products, Review
Products, Show Related Products, Close and Validate Postal Code.

I hope this helps some.


Tom Wickerath
Microsoft Access MVP
https://mvp.support.microsoft.com/profile/Tom
http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________
 
I do know how to create and execute a macro in Access. I did this about a
decade or more ago. So are you telling me Access automatically runs a macro
named "Autoexec" at startup?
 
David Portwood said:
I do know how to create and execute a macro in Access. I did this about a
decade or more ago. So are you telling me Access automatically runs a macro
named "Autoexec" at startup?

Yes it does. One can hold down the shiftkey while opening the database to bypass the autoexec macro (it will also bypass anything you set in Tools Startup). You can also disable the shiftkey bypass. Look for 'By Pass Shift Key Code' at Albert Kallal's site http://www.members.shaw.ca/AlbertKallal/msaccess/msaccess.html
 
Hi David,

I did not receive an autonotification of your latest reply until 6:10 AM
this morning, nearly 24 hours after you replied! I see Joan picked up this
thread. Thanks Joan.

I think you would do good to invest in a few Access books. Here is a site
that shows lots of good books:

http://www.accessmvp.com/JConrad/accessjunkie/resources.html#Books

If you can only afford one book, my recommendation is to pick out a book
written by John Viescas.


Tom Wickerath
Microsoft Access MVP
https://mvp.support.microsoft.com/profile/Tom
http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________
 
hey if you want more help from Tom, you could probably call him

I found his address and phone number at zabbasearch.com


TOM G WICKERATH
15851 12TH PL
BELLEVUE, WA 98008 (425) 562-8913
 
hey if you want more help from Tom, you could probably call him

I found his address and phone number at zabbasearch.com


TOM G WICKERATH
15851 12TH PL
BELLEVUE, WA 98008 (425) 562-8913
 
Warning

Usage of Access Databases is no longer the reccomended way to use Access
Forms and Reports.

you should move to Access Data Projects
 
Maybe you should stop drinking and driving

I saw you drinking and driving the other day; I will report your license
plate number the next time I see you
 

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

Back
Top