Binding tick box causing problems (1 Viewer)

ukmale65000

Registered User.
Local time
Today, 19:45
Joined
Nov 28, 2007
Messages
52
I have a form which contains an unbound check box, when selected several hidden questions appear due to the code below :
Private Sub Check58_AfterUpdate()
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.Tag = "showd" Then
ctl.Visible = Me.Check58
End If
Next ctl
If Me.Check58 Then Me.Check58.Locked = True

End Sub
This works fine however if the user saves the record then renters it to make any additions, the checkbox is no longer ticked, reticking it again reveals the questions and indeed the answers typed in previously.
I thought it was due to check 58 being unbound, so i add a field to my table and made this the control source for the checkbox, this is where my problem lies as the system hangs before it starts and the debugger shows

Private Sub Form_Current()
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.Tag = "showd" Then
ctl.Visible = Me.Check58
End If
Next ctl

For Each ctl In Me.Controls
If ctl.Tag = "showp" Then
ctl.Visible = Me.Check60
End If
Next ctl


End Sub

Can anyone see where i am going wrong?
 

KenHigg

Registered User
Local time
Today, 14:45
Joined
Jun 9, 2004
Messages
13,327
There are several other things that look odd about your method but I'm guessing you need to account for nulls.
 

ukmale65000

Registered User.
Local time
Today, 19:45
Joined
Nov 28, 2007
Messages
52
The majority of records will have a null value for the check box and its is only occasionally that the supplimentry questions are needed. thast why they remain hidden until the check box is chosen. I dont understand why, by binding the box the system crashes.
 

Users who are viewing this thread

Top Bottom