Toggle between maximized forms

B

bhammer

Access2003

Why can't I do this with SetFocus?

Two forms are opened and maximized (using the handy module alxmdlReports
that I modified to work with forms, too). My toolbar has buttons to open both
forms. Once the forms are opened, I want them to work like the
Windows>ActiveWindow menu, or like ALT+TAB to toggle between opened windows,
switching the 'back' window to the 'front'.

I have code on the toolbar button that checks for IsLoaded (myForm) = True

If the form is already loaded, then just make active the other form.
SetFocus seems to do nothing.

Here's the code I have in a Module in the Function behind the button to open
(or goto) the frmByAddress form:

Public Function fOpenfrmByAddress()

Dim strDocName As String
strDocName = "frmByAddress"

If IsLoaded(strDocName) Then
MsgBox "Yes, " & strDocName & " IsLoaded.", , "fOpenfrmByAddress"
Forms.frmByAddress.SetFocus
Else
DoCmd.OpenForm strDocName
alxMaxForm 0, strDocName
End If


Shouldn't this work?
 
J

Jeanette Cunningham

Hi bhammer,
Forms.frmByAddress.SetFocus is not the correct syntax.

Change it to Forms("frmByAddress").SetFocus

I haven't tested this so I don't know if this will work without also making
the unwanted form hidden.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 

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

Similar Threads


Top