IsOpen Problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form "frmTimeSheetDetail" that has a search combo box. It works
fine When I open it, but I don't want the cbo box to be visible when it is
used as a sub form inside "frmTimeSheet". Can you tell me what I am doing
wrong? When I debug "IsOpen" is Highlighted.

Private Sub Form_Load()
If IsOpen("frmTimeSheet") Then
Me!txtSearchField.Visible = False
Else
Me!txtSearchField.Visible = True
End If
End Sub

Thank You!
 
KPE said:
I have a form "frmTimeSheetDetail" that has a search combo box. It
works fine When I open it, but I don't want the cbo box to be visible
when it is used as a sub form inside "frmTimeSheet". Can you tell me
what I am doing wrong? When I debug "IsOpen" is Highlighted.

Private Sub Form_Load()
If IsOpen("frmTimeSheet") Then
Me!txtSearchField.Visible = False
Else
Me!txtSearchField.Visible = True
End If
End Sub

There's no built-in function called "IsOpen". You could check for the
form's being open this way:

If CurrentProject.AllForms("frmTimeSheet").IsLoaded Then

However, that's not actually testing whether the particular instance of
frmTimeSheetDetail that you're running this code in is the one that is
being used as a subform on that form. Instead of just testing whether
frmTimeSheet is open, I would test to see if this form is being used as
a subform. You can do it by way of the subform's Parent property, which
will yield a reference to the parent form if there is one, or raise an
error if not:


Private Sub Form_Load()

Dim strParent As String

On Error Resume Next
strParent = Me.Parent.Name

Me!txtSearchField.Visible = (Len(strParent) = 0)

End Sub
 
Dirk Goldgar said:
There's no built-in function called "IsOpen". You could check for the
form's being open this way:

If CurrentProject.AllForms("frmTimeSheet").IsLoaded Then

However, that's not actually testing whether the particular instance of
frmTimeSheetDetail that you're running this code in is the one that is
being used as a subform on that form. Instead of just testing whether
frmTimeSheet is open, I would test to see if this form is being used as
a subform. You can do it by way of the subform's Parent property, which
will yield a reference to the parent form if there is one, or raise an
error if not:


Private Sub Form_Load()

Dim strParent As String

On Error Resume Next
strParent = Me.Parent.Name

Me!txtSearchField.Visible = (Len(strParent) = 0)

End Sub

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

Thank You, I have a Access Book that shows "IsOpen" code for something else, I don't know how that worked but I do know your way worked. thanks again
 

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

Back
Top