MsgBox appearing underneath modal form

W

Wayne

Hi all,

I have a form that loads at startup, called by the AutoExec macro. It's a
modal form which is more of a semi-intelligent splash screen. The form checks
the database location, and if the location fails a string comparison with
it's expected location (i.e. someone has copied the database to their desktop
rather than create a shortcut) it will warn them and ask them if they are
sure they want to open this file. It does this via a msgbox (vbYesNo).

Sometimes this msgbox displays in front of the modal form, but sometimes it
displays behind the modal form. If it displays behind the modal form, you
only need to click anywhere within the dialog box and access will repaint it
in front of the modal form. There is no consistency - if you open the
database repeatedly and the condition is met, sometimes the msgbox will be in
front, and sometimes behind the form.

Does anyone have any idea how/why this is occurring, and how I can prevent
this? The form needs to be modal as it is used elsewhere in the product as a
loading screen.

Thanks!
 
D

DomThePom

Tried to replicate your problem and failed!

if msgbox is in the form open event I see only the message box initially -
the form only appears after clicking on the message box.

Why not just set auto centre property to false and move form out of the way
so it will not conflict the the message box?

Incidentally, unless you are using an old version you do not need an
autoexec macro - just go to Tools start uo and select the form that you want
to open on start up.
 
D

DavidBoyle via AccessMonster.com

Before you display the message box set the visible property of the code to be
false using the me KEYWORD

Your code will look like this

if somecondition=true
ME.VISIBLE=FALSE 'turns the form off because we want to be sure to
see the message
If NOT msgbox("some problem here buddy!",vbyesno+vbexclamation)=vbyes THEN
APP.QUIT
ELSE
ME.VISIBLE=true ' user wants to stick around so turn the form back on
END IF
end if
 
W

Wayne

Oops, I just realised I typed my query wrong.

The msgbox is not called by the form, it is called by the same function that
opens the form. Here's the code...

'**************************

DoCmd.OpenForm "StartUpForm"
Form_StartUpForm.WorkingLabel.Caption = "Starting Up..."
Form_StartUpForm.Repaint

If CheckFileLocation = False Then
intResponse = MsgBox("This tool has been launched from an invalid
location." & Chr(13) & Chr(13) & "The file you are using may not link to the
national database. Are you sure you wish to open this file?", 52, "Confirm")
If intResponse = 7 Then
Application.Quit
Exit Function
End If
End If

'**************************

The form 'StartUpForm' does nothing on open (there's no code for the open or
load event). The code then calls a function 'CheckFileLocation' which
compares the database's path to what it should be, and returns 'False' if
things aren't as they should be. This is where the Msgbox displays, which is
sometimes in front of, and sometimes behind the modal form.
 

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