Reveal subform when clicking cmd button

ukmale65000

Registered User.
Local time
Today, 12:52
Joined
Nov 28, 2007
Messages
52
I currently have a command button on my main form, and am trying to get a list of supplimentry questions to appear when i press the command button.
Currently the code i use is
Private Sub cmd_nds_Click()
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.Tag = "showx" Then
ctl.Visible = Me.cmd_nds
End If
Next ctl
End Sub
This does not work with the line " ctl.Visible = Me.cmd_nds
" being highlighted any idea why?

Thanks in advance
 
A regular button has no value. If you want to toggle the visibility, use a toggle button instead of a regular button.
 
Have changed to a toggle button, can you tell me what the code should now read for the on click function
I have tried
Private Sub Toggle88_Click()
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.Tag = "showx" Then
ctl.Visible = Me.Toggle88

End If
End Sub
but it dosent work
 
Have you put "showx" in the tag property of the controls you want affected? That code looks okay to me. Can you post the db?
 
Oh, I didn't notice you dropped the

Next ctl

that you had in the original code. You need to put it back.
 
Ok have put that back now get an error message Next without For ??

This is the code i have in place
Private Sub Toggle88_Click()
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.Tag = "showx" Then
ctl.Visible = Me.Toggle88
Next ctl
End If

End Sub
Im pulling whats left of my hair out can you help?
 
It needs to be after the End If line.
 

Users who are viewing this thread

Back
Top Bottom