471,578 Members | 1,513 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,578 software developers and data experts.

Call Subform Function From Main Form

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
2 3648
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
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.

Similar topics

2 posts views Thread by Andante.in.Blue | last post: by
4 posts views Thread by aqua404 | last post: by
2 posts views Thread by David W. Fenton | last post: by
6 posts views Thread by DMUM via AccessMonster.com | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by lumer26 | last post: by
reply views Thread by Vinnie | last post: by
1 post views Thread by lumer26 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.