Setting focus to newly opened database.

gold007eye

Registered User.
Local time
Yesterday, 22:34
Joined
May 11, 2005
Messages
260
I have been racking my brain for months trying to figure this dilema out. What I have is multiple databases (used for different functions/departments) that can be open at one time. I have designed most of them to to be pop-up (more app looking than access db) databases (using the acCmdAppMinimize command). The problem I am having is that if one of the databases is already opened & minimized and I open another database it brings the previous database back into focus instead of the newly opened database. Does anyone know how to fix this?

Example: I currently have PELA Database open. I then minimize PELA and now click and open PERD Database. When PERD is opening PELA comes back to focus and then has to be re-minimized to get the focus back to PERD.

Here is a link to show an example of what is happening: (Hope someone can help me fix this)

http://www.listenloudly.com/AccessDB/Example.htm
 
I have a similar problem, even without multiples. I just have 1 app which opens a main form and hides Access (acCmdAppMinimize).

It always opens with the form not in focus, so if there are other programs running, the app opens in the background and user has to Alt-Tab or taskbar to it.
 
Have you got any of the following:

1) AutoExec macro to open a form
2) Tools ===>StartUp and select a form to be opened from the field labelled "Display Form/Page:"

Dave
 
Not to hijack this posting, but while we're discussing acCmdAppMinimize, I've got two small apps, both single form set to popup/modal and in fact, all settings identical (including everything in Tools > Startup) that I use acCmdAppMinimize on. One opens as I want it; nothing of Access showing, while the other shows all Access menus. On this one, if I uncheck everything in Startup it still shows the very basic menu (File Window Help)

An ideas?

BTW, I haven't experienced the problem with focus on these forms! Go figure!

Thanks!
 
Have you got any of the following:

1) AutoExec macro to open a form
2) Tools ===>StartUp and select a form to be opened from the field labelled "Display Form/Page:"

Dave

I've actually tried it with both. Surprisingly, Autoexec runs a bit faster, but either way I see Access for a second before it's minimized (I would like to NOT see Access :) I prefer not to have an Autoexec macro, it just seems cheesy with all the code I write :D Is there such a thing as an Autoexec module?

Now, a blank Access app with just a form (set to PopUp and to minimize Access when form loads), opens the form in Focus just fine.

I happen to have other On_Load stuff that runs and I think it might cause the form to loose focus, but I don't know how:

Code:
Private Sub Form_Load()
'Only enable report buttons when they contain data
Dim frm As Form
Dim ctl As Control
Dim strSubform As String
Dim blnErr As Boolean

Dim dbs As DAO.Database
Dim obj As Object
Dim s As String
Dim intX As Integer

Const DB_Text As Long = 10
Const NOPROPERTY_ERR = 3270

On Error GoTo Err_Form_Load
       
'set Current Database object variable:
Set dbs = CurrentDb

'set Application icon:
s = Left(CurrentDb.Name, Len(CurrentDb.Name) - Len(Dir(CurrentDb.Name))) & "\" & IBW_LOGO
    
intX = AddAppProperty("AppIcon", DB_Text, s)
    
'Set form icon:
SetFormIcon Me.hWnd, Left(CurrentDb.Name, Len(CurrentDb.Name) - Len(Dir(CurrentDb.Name))) & "\" & IBW_LOGO
'**************

'Only enable Report Buttons with data:
Set frm = Me
For Each ctl In frm.Controls

    If Left(ctl.Name, 11) = "cmdMismatch" Then
        If Me.Controls(ctl.Name).Enabled = False Then
            strSubform = ctl.Caption
            'don't remove this debug.print line, because it triggers the needed Err, which is then handled!
            Debug.Print Me.Controls(strSubform).Form!match.Value
            If blnErr = False Then
                Me.Controls(ctl.Name).Enabled = True
                Debug.Print Me.Controls(strSubform).Form!match.Value
            End If
        End If
    End If
    
    blnErr = False  'reset variable
    
Next

'Update title bar on screen.
Application.RefreshTitleBar

Me.cmdHelp.SetFocus

Exit_Form_Load:
    Exit Sub
    
Err_Form_Load:
    Select Case Err
        Case 2427                   'error generated because subform has no value
            blnErr = True
            Resume Next
        
        Case NOPROPERTY_ERR         'property doesn't exist
            Set obj = dbs.CreateProperty("AppTitle", dbText, IBW_TITLE)
            dbs.Properties.Append obj
            Resume Next
        
        Case Else
            MsgBox Err.Description, , Err.Number
            Resume Exit_Form_Load
    End Select

End Sub
 
Not to hijack this posting, but while we're discussing acCmdAppMinimize, I've got two small apps, both single form set to popup/modal ...

It's not really your question, but "modal" is not really needed for acCmdAppMinimize method :) (but it IS needed for the API).

Edited: BUT... I just noticed, that if you DO set it also to Modal, users can't right click the Taskbar icon of the app to restore the hidden Access! They can't close the app from the taskbar, but I really prefer it this way. I was gonna look into that later in the development, but found this solution accidentally :)

Without "Modal" users can right-click the app taskbar icon and click "Restore" on the standard menu and Access returns. Not good. But maybe there's a better way for this, so that users can still Close the app from righ-click?

(sorry for hijacking the thread right back :D)
 
Last edited:
Ok, another odd thing about focus. I mentioned that another blank dummy app with only 1 form opens with the form in focus.

Not really. What REALLY happens is that when I open the app from any folder, it becomes the active program on top (my actual app as well as the test dummy app).

If I open any of the apps from the Desktop, it opens behind active window (whatever current program) or if there are no active windows it's visible, but without focus (until clicked or switched to).

Problem is, even if the file is in a folder, but shortcut is on the Desktop, it still opens WITHOUT focus :-(

I don't like that! Anybody? Microsoft?
 
Have you tried creating a batch file to call the application and run that from the desktop (or a shortcut to the batch file).
 
Have you tried creating a batch file to call the application and run that from the desktop (or a shortcut to the batch file).

actually, i don't know much about batch files. i've observed someone editing old windows 3.11 .bat files years ago, but don't know anything about how they're used now.

would the user be clicking on a batch file? thanks.
 

Users who are viewing this thread

Back
Top Bottom