Autoexec type of macro? Or should I be looking for code (not found so far).

  • Thread starter StargateFanFromWork
  • Start date
S

StargateFanFromWork

I feel like such a dork lately <g>! I just can't seem to figure this out in
A2K: if something is set in the TOOLS > STARTUP > Display Form/Page: and we
have the "switchboard" listed there - can these startup "instructions" be
found in an actual "macro" somewhere in the vb editor? Or is this something
done behind the scenes?

The reason I ask is this (unless I'm completely on the wrong track):

- if it's not in a macro, then perhaps I can go ahead and remove that
functionality from the startup, and then
- attempt to figure out how to get an "autoexec" type of macro to work
which will do what the startup does but also, additionally, open and
minimize the main table.

When we have this table open, that really seems to increase the speed by
which A2K can locate and move around records. Which makes sense to me; the
table is already open so Access can read it much more quickly than over the
LAN.

Thanks. :blush:D
 
J

Jeff Boyce

Another approach would be to create your own Main Menu form, and set that
form in startup. Using the startup window, you can also hide the Database
Window on startup.

I'm not at all clear why you would be having a table opened on startup?

Regards

Jeff Boyce
<Office/Access MVP>
 
G

Guest

There are no Macros in the VB Editor. The VB Editor gives you access to the
VBA code in your application.
You create any code within the Switchboard. It is just an easy way to
create a Form based menu system.
To do what you want to do will not be that difficult. You can remove the
reference to the Switchboard in the Display Form/Page: and create a Macro
named Autoexec. When Access starts up and there is no form or page
identified, then it looks for a macro named Autoexec and runs it.
You could open the table minimized, then run your Switchboard from the macro.
Now, you have stumbled on one of the performance tricks of Access. Certainly
having the main table open will let you get to it faster, but, it would not
have to be that table. One of the performance tricks of developing an Access
application is on start up to open any old table. Many developers use a
catch all table that might keep information they need for the application,
but isn't used by the users. They keep this table open as long as the mdb is
open. This is called a "persistant" connection. It makes opening any other
table in the back end database much faster, because the front end database
does not have to go find the back end each time there is a request to open a
table.
I would suggest you consider such an approach. There are down sides to
keeping your main data table open all the time, but that is for another topic
session.
 
S

StargateFanFromWork

Hi, Klatuu (is that your real name? Kewl! Sounds a lot like "Klaatu barada
nikto"! http://www.tauspace.freeserve.co.uk/day_the_earth_06.htm <g>)

Well, for the first time I got somewhere in the Access vb editor <vbg>.
That's saying a lot as it's so different from Excel! <phew>

I created the Autoexec "macro", which newbie-speak for me just means I tried
to put the coding in the vb editor. I've always just called them macros but
I'm guessing that that's probably the wrong word. Anyway, no matter where I
put it, nothing worked so I'm obviously doing something wrong. I'm flying
blind, though, you see. All the code I've looked at in all the examples
I've opened so far have the switchboard open via the startup so it's hard to
visualize what I've never seen. I stuck that Autoexec code _everywhere_; in
various forms, esp. the switchboard vb coding area, and even in module1. No
luck. _But_, I did finally see 2 references in one of the "macros" in the
"Form_Open" one in the switchboard - one line reference says

' Minimize the database window.

and the other says:

' Move to the switchboard page that is marked as the default.find by
the forms ...

So it seems that that works. I put the switchboard back on in startup and
this in the switchboard code area at the top and at least the database
window is now minimized with this code, which I've copied here below:

******************************
Private Sub Form_Open(Cancel As Integer)
' Minimize the database window and initialize the form.

On Error GoTo Form_Open_Err

' Minimize the database window.
DoCmd.SelectObject acForm, "Switchboard", True
DoCmd.Minimize

' Move to the switchboard page that is marked as the default.
Me.Filter = "[ItemNumber] = 0 AND [Argument] = 'Default' "
Me.FilterOn = True

Form_Open_Exit:
Exit Sub

Form_Open_Err:
MsgBox Err.Description
Resume Form_Open_Exit

End Sub
******************************

You've all been so very patient and I really appreciate that. Hopefully,
though, I can end the day on even more positive results and hope you don't
mind - is there a way to make the switchboard maximize somewhere in the
above code? I find that if it's in that state, any forms I then open from
the switchboard will all be maximized which is good for us. Our forms in
this solution are rather heavily populated with items (fields and sub-forms)
so we can see really only see it all comfortably when the screen is
maximized. (I'm not the developer, she's done a fabulous job but I'm just
fixing my front-end to be much more user-friendly).

I'll worry tomorrow or another day about that table you speak of. I think
that's a great idea but don't know where I'm heading with that yet to make
it happen. I feel confident for the first time in making more headway with
an Access manual and will go again to the library to see what they have
again.

Thanks so much and appreciate everyone's help and hopefully that "macro"
above can accommodate a maximize command! :blush:D

Klatuu said:
There are no Macros in the VB Editor. The VB Editor gives you access to the
VBA code in your application.
You create any code within the Switchboard. It is just an easy way to
create a Form based menu system.
To do what you want to do will not be that difficult. You can remove the
reference to the Switchboard in the Display Form/Page: and create a Macro
named Autoexec. When Access starts up and there is no form or page
identified, then it looks for a macro named Autoexec and runs it.
You could open the table minimized, then run your Switchboard from the macro.
Now, you have stumbled on one of the performance tricks of Access. Certainly
having the main table open will let you get to it faster, but, it would not
have to be that table. One of the performance tricks of developing an Access
application is on start up to open any old table. Many developers use a
catch all table that might keep information they need for the application,
but isn't used by the users. They keep this table open as long as the mdb is
open. This is called a "persistant" connection. It makes opening any other
table in the back end database much faster, because the front end database
does not have to go find the back end each time there is a request to open a
table.
I would suggest you consider such an approach. There are down sides to
keeping your main data table open all the time, but that is for another topic
session.
out in

(still do, though feeling a little better <g>).

[snip]
 
J

John Vinson

All the code I've looked at in all the examples
I've opened so far have the switchboard open via the startup so it's hard to
visualize what I've never seen. I stuck that Autoexec code _everywhere_; in
various forms, esp. the switchboard vb coding area, and even in module1. No
luck.

Stick it in the Switchboard form's Open event (as an Event Procedure,
use the ... icon and choose "Code Builder").

Access (unlike current versions of Excel) has both VBA code - Event
Procedures, commonly, or standalone Modules - and *also* the older,
more limited Macros. Macros are sort of a keystroke-by-keystroke
emulation of user interaction; it's perfectly possible to use them for
a number of simple tasks, if you want to avoid having any VBA code in
your database; or you can avoid them altogether.

John W. Vinson[MVP]
 
S

StargateFanFromWork

John Vinson said:
Stick it in the Switchboard form's Open event (as an Event Procedure,
use the ... icon and choose "Code Builder").

Access (unlike current versions of Excel) has both VBA code - Event
Procedures, commonly, or standalone Modules - and *also* the older,
more limited Macros. Macros are sort of a keystroke-by-keystroke
emulation of user interaction; it's perfectly possible to use them for
a number of simple tasks, if you want to avoid having any VBA code in
your database; or you can avoid them altogether.

Okay, I see that I'm getting to the same place but going through the vb
editor and having the "switchboard" form clicked on in the "Microsoft Access
Class Objects" pane of the editor. That's a relief.

Lots of small issues for me to iron out still. If I have a chance tonight
once I manage to get out of here and go home <g>, I'm going to search for
sample db's online to try to find one again that has different types of
coding to what is found in the sample db's. Hopefully one has an Autoexec
"macro" that does things like open up the Switchboard and other forms and
that doesn't use the startup at all.

Thanks for the confirmation on where to put Autoexec coding. Cheers! :blush:D
 

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