Enumerating control in sub form, how to

S

SF

Hi,

I have two functions which use to switch langauges (form labels on and off)
when a function is selected.

Public Function Language_Eng()
Dim frm As Form
Dim sfrm As SubForm
Dim ctl As Control
Dim ctls As Control

Set frm = Screen.ActiveForm.Form
For Each ctl In frm.Controls
If ctl.Tag = "k" Then
ctl.Visible = False
End If
If ctl.Tag = "e" Then
ctl.Visible = True
End If
Next ctl
End Function

Public Function Language_Khm()
Dim frm As Form
Dim sfrm As SubForm
Dim ctl As Control

Set frm = Screen.ActiveForm.Form
For Each ctl In frm.Controls
If ctl.Tag = "k" Then
ctl.Visible = True
End If
If ctl.Tag = "e" Then
ctl.Visible = False
End If
Next ctl
End Function

These two functions work fine for those form that do not have subform. How
do I add code to turn visibility of label on/off for a subform if present?

SF
 
T

TC

Use ctl.controltype = acsubform to see if the control is a subform. If so:

for each ctl2 in ctl.form.controls ' <- the subform's controls.
...

Of course, that just handles one level of subforms. Add more code to handle
more levels!

HTH,
TC
(off for the day)
 

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

Top