Startup Question

Shep

Shep
Local time
Today, 16:17
Joined
Dec 5, 2000
Messages
364
Greetings all,
I want my main form to open at the top left corner of the screen when the database is opened, but I can't figure a way to get the event to occur AFTER the menu bars are closed. Hope that's clear enough..

I only want the user to have the main File menu bar, with my form at the top left of the screen just below that. In the Startup options I have turned off all menu bars but it seems that is not done until after my form is open. Hence, the form opens at the top left of the available space...then the menu bars are closed, leaving a gap between the remaining File menu and the top of my form.

Thanks...
 
Since you are dealing with a Windows action (to turn off an application's toolbar completely), you have to let Windows do its thing. Access doesn't manage its own tool bar, it just specifies something to Windows, then lets Windows make the displayed change.

"Letting Windows do its thing" is done by calling DoEvents (if I recall the name correctly, I'm shooting from the hip right now.) This allows Windows a chance to run and handle any pending events - such as toolbar changes, task exits, icon changes (like wastebasket changing from empty to full...).

Once you have turned off the toolbar, call DoEvents, THEN open your form at the appropriate location. The worst that will happen is that I'm wrong, but it should be an easy thing to try. Look for it in the help files beforehand to get the spelling right and to learn what Help has to say about the call.
 
Thank you sir, and no worries whether or not you're wrong, I'm happy to have your insight on the matter. I'll read up on the function and let you know.

Many thanks
 
I couldn't find a single place where DoEvents allowed the toolbars to finish arranging, and then open the main Form. The knowledge base swears that the Timer Event is preferable for all instances where you want to yield control or to give the user an opportunity to cancel a process...tried it and it's satisfactory. This application is all contained on one tabbed form, so I guess it's ok by me. I've had problems in the past with the Timer causing the screen to flicker, but it seems ok now. I guess I'll stick with it unless I have problems.

Thanks again Doc Man.
 
Rich said:
Why not just use an AutoExec macro ?

Rich, I thought macro's were only for newbees and insurance salesmen.
Any VBA coding instead ?
 
rak said:
Rich, I thought macro's were only for newbees and insurance salesmen?

There's always one exception - a macro called autoexec is such a case. I'd just select the RunCode option within it and then write a function to do what I want though.
 
That's right Mile......

the close Dbase macro would look something like :
action .... runcommand and command "Exit".
Why use action ... Runcode with a reference to a function name.

As you said, this is one of the exceptions , but why still using a macro to refer to a (VB) function ?
 
One wouldn't use a Macro to close a db, the code can be written for a button. An autoexec Macro fires when the db first opens without user intervention. Try writing a Macro that replaces this code

Declare Sub SetWindowPos Lib "User32" (ByVal hWnd&, _
ByVal hWndInsertAfter&, _
ByVal X&, ByVal Y&, ByVal cX&, _
ByVal cY&, ByVal wFlags&)

Global Const HWND_TOP = 0
Global Const SWP_NOZORDER = &H4


Function SizeAccessWdow()
Dim cX As Long, cY As Long, cHeight As Long
Dim cWidth As Long, H As Long
H = Application.hWndAccessApp

cX = 15
cY = 15
cWidth = 650
cHeight = 500

SetWindowPos H, HWND_TOP, cX, cY, cWidth, cHeight, SWP_NOZORDER

End Function
 
you got me there Rich....
It just amused me (after all the VB versus macros's discissions) ... you came up with an autoexec macro.

Personally I use the autoexec macro only to quit/close the db , hence my response.
 
An autoexec macro only fires on startup, how can you use it to close your db?
 
right again... my mistake I named my macro Autoexit for whatever reason and mixed up the terms.
 
There's no point in using a macro to close the db, or very little else for that matter ;)
Just add

DoCmd.Quit

instead of your macro
 
rak said:
why still using a macro to refer to a (VB) function ?

When I open a database I want to set a number of things, I want to ensure I have a hidden form, etc.

The autoexec macro runs on startup without any interaction from the user.

By running a function from the macro I am able to look at the user who is opening the database - determine if they have bene given access to it (and shut down if not), determine what permissions they have within the database - data entry, reporting, administration, etc. and show corresponding forms only. I can also set a number of public variables that I may need. And, I can trap any errors that I haven't foreseen.
 
Rich said:
There's no point in using a macro to close the db, or very little else for that matter ;)
Just add

DoCmd.Quit

instead of your macro


OK Done.
I have included the command to compact the Dbase before closing
since his was a part of my exit macro.

Thanks for the suggestion though.
 
What version of Access are you using? I'm sure newer ones have a compact on close option without using code
 
I'm using Access 2002

Yes ...found the compact on close option in the tools--options--
menu.
Learning every day.
Thanks again
Cheers, Ron
 
Actually I did try an AutoExec macro which called a Function...yet I couldn't seem to write one that would MoveSize my main form after the toolbar sequence was finished. Then again, I'm still new after 5 years :)
 
No way...you write one and post it and I'll look heh heh :)
 

Users who are viewing this thread

Back
Top Bottom