Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

.visible problem 1

Status
Not open for further replies.

norason

Programmer
Joined
Jan 28, 2009
Messages
139
Location
US
I've had this basic code working for quite some time in a program. I just added it to a new form to know when it was visible, but for some reason, the .visible never works. Here is the same code on a little test program that just toggles back and forth between two forms, but never shows .visible. What is wrong?

Private Sub Command1_Click()
Form2.Show
End Sub

Private Sub Form_Load()
Dim frm As Form
Unload Form2
For Each frm In Forms
If frm.Name = "Form1" Then
If frm.Visible Then
Debug.Print "form 1 visible"
End If
Exit For
End If
Next
End Sub



Private Sub Command1_Click()
Form1.Show
End Sub

Private Sub Form_Load()
Unload Form1
For Each frm In Forms
If frm.Name = "Form2" Then
If Form2.Visible Then
Debug.Print "form 2 visible"
End If
Exit For
End If
Next
End Sub


Thanks,

Gary
 
A Form is not Visible until the code in its Load Event has completed unless that code includes Show.

Try placing your detection code in the Form_Activate Event (or after a Show in the Load Event).
 
HughLerwill,

That's just what I needed - thanks - it's working fine now.

Gary
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top