By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,575 Members | 1,413 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,575 IT Pros & Developers. It's quick & easy.

Call Subform Function From Main Form

P: n/a
I have a form (frmAppointment) with a subform on it
(frmAppointmentsub1). I have placed a command button on the main form
which calls the function below from the module. The purpose of this
function is to make fields beginning with YY invisble OnClick of the
command button on the main form. It works for the fields on the main
form but not on the subform. What do I need to add or do to make it
work on the subform? Any help would be most appreciated.

Thank You
TD

The command button on the main form event procedure is:

Private Sub cmdYY_Click()

Dim I As Integer
I = glrInvisbleFields(Me)

End Sub
The module function is:

Function glrInvisbleFields(F As Form)

Dim I As Integer
Dim C As Control
Dim X As Variant

For I = 0 To F.Count - 1
Set C = F(I)

If Left$(C.Name, 2) = "YY" Then
C.Visible = False

End If
Next I
End Function
Nov 13 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
If the subform control on the main form is named sbfF, then you could add:

I = glrInvisible(Me.sbF.Form)

There's no code in what you show that addresses the Form embedded in the
Subform control. It can be addressed as "Me" only from its own Form's class
module, not from the main form.

Larry Linson
Microsoft Access MVP

"TDIOwa" <td****@hotmail.com> wrote in message
news:f0**************************@posting.google.c om...
I have a form (frmAppointment) with a subform on it
(frmAppointmentsub1). I have placed a command button on the main form
which calls the function below from the module. The purpose of this
function is to make fields beginning with YY invisble OnClick of the
command button on the main form. It works for the fields on the main
form but not on the subform. What do I need to add or do to make it
work on the subform? Any help would be most appreciated.

Thank You
TD

The command button on the main form event procedure is:

Private Sub cmdYY_Click()

Dim I As Integer
I = glrInvisbleFields(Me)

End Sub
The module function is:

Function glrInvisbleFields(F As Form)

Dim I As Integer
Dim C As Control
Dim X As Variant

For I = 0 To F.Count - 1
Set C = F(I)

If Left$(C.Name, 2) = "YY" Then
C.Visible = False

End If
Next I
End Function

Nov 13 '05 #2

P: n/a
Wow You get the honor of today's bingo award!!!

Thanks alot Larry!

TD
*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.