MDE Loses Focus on Run

Tezcatlipoca

Registered User.
Local time
Today, 13:01
Joined
Mar 13, 2003
Messages
246
Just a quick one. I have a split database written in Access 2003 with a ton of VB code running most of the features. The whole database works beautifully.

One feature of the database is that when started, Access itself is minimized and the first form (a modal popup) appears on the user's screen. All the forms are modal popups, so the user can use the database without ever seeing or getting into Access behind. All this works great...

...except when in MDE. I turn my main FE MDB into an MDE and all looks fine. The database functions as it should, all the features work fine and there are no errors. However, one thing I have noticed is that in MDB format, you start the database, it minimizes Access, then focus is placed on the first form, as should be.
In MDE, the database starts, it minimizes Access, but focus is immediately lost. This is not only undesirable, but it of course means that if you have something else open on screen (such as the folder from which you might be running the database), the first form is sent to the back.
Sure, you can still click on the application in the taskbar and focus pops right back to the main form, but I'd rather it happened automatically as it does in the MDB version.

My first form's OnLoad code is:

Code:
Private Sub Form_Load()
    RunCommand acCmdAppMinimize
    Me.SetFocus
End Sub

with an autoexec macro doing the actual opening of the form. Any ideas as to why the focus loss?


In addition, as someone who is comfortable with all versions of Access up to and including 2003 but has never played with 2007, am I going to run into issues with trying to run my MDE on a 2007 machine?
 
Last edited:
Private Sub Form_Load()
RunCommand acCmdAppMinimize
Me.SetFocus
End Sub

does that work?
how can you set the focus to a minimized application?
 
does that work?
how can you set the focus to a minimized application?

Indeed not; the Me.SetFocus was the remains of some form code that used to sit between the minimize command and it and set the focus to one of the popup forms, which got accidentally left in. It was missed as did nothing, but thanks for spotting it; now removed! :)

However, the original issue still stands. I just can't seem to make my MDE keep window focus on the main application, whilst the MDB version works perfectly. :mad:
 

Users who are viewing this thread

Back
Top Bottom