G
Guest
Hello,
I have the following code behind a checkbox on my form that is set to
'Continuous Records' for its Default View with the thought that I can lock
the current record once the checkbox is checked and then proceed to enter
subsequent records. I thought I had it working, but checking it now, it is
not. Here is the code:
Private Sub record_monitored_AfterUpdate()
On Error Resume Next
Dim ctl As Control
Dim frm As Form
Dim LockValue As Boolean
'If MsgBox("Checking the Monitored Box will lock this record. Is this OK?",
vbYesNo) = vbYes Then
For Each ctl In frm.Controls
With ctl
Select Case .ControlType
Case acTextBox
If Forms!fIndepConcomMeds!record_monitored <> 0 Then
ctl.Locked = LockValue
Else
ctl.Locked = False
End If
Case acComboBox
If Forms!fIndepConcomMeds!record_monitored <> 0 Then
ctl.Locked = LockValue
Else
ctl.Locked = False
End If
Case acListBox
If Forms!fIndepConcomMeds!record_monitored <> 0 Then
ctl.Locked = LockValue
Else
ctl.Locked = False
End If
Case acCheckBox
If Forms!fIndepConcomMeds!record_monitored <> 0 Then
ctl.Locked = LockValue
Else
ctl.Locked = False
End If
Case acToggleButton
If Forms!fIndepConcomMeds!record_monitored <> 0 Then
ctl.Locked = LockValue
Else
ctl.Locked = False
End If
Case acCommandButton
If Forms!fIndepConcomMeds!record_monitored <> 0 Then
ctl.Locked = LockValue
Else
ctl.Locked = False
End If
Case acSubform
If Forms!fIndepConcomMeds!record_monitored <> 0 Then
ctl.Locked = LockValue
Else
ctl.Locked = False
End If
Case acOptionGroup
If Forms!fIndepConcomMeds!record_monitored <> 0 Then
ctl.Locked = LockValue
Else
ctl.Locked = False
End If
Case acOptionButton
If Forms!fIndepConcomMeds!record_monitored <> 0 Then
ctl.Locked = LockValue
Else
ctl.Locked = False
End If
End Select
End With
Next ctl
Set ctl = Nothing
Set frm = Nothing
'End If
End Sub
When I get to the ' Select Case .ControlType' line using the Debugger, it
immediately skips all the way down to 'End Select', and soon then to 'End
Sub', so none of the controls in the current record are locked.
Why is it skipping directly to the 'End Select'? I do have similar code in
the Form's 'On Current' Event as well, and am not sure if this is interfering.
Thank you.
I have the following code behind a checkbox on my form that is set to
'Continuous Records' for its Default View with the thought that I can lock
the current record once the checkbox is checked and then proceed to enter
subsequent records. I thought I had it working, but checking it now, it is
not. Here is the code:
Private Sub record_monitored_AfterUpdate()
On Error Resume Next
Dim ctl As Control
Dim frm As Form
Dim LockValue As Boolean
'If MsgBox("Checking the Monitored Box will lock this record. Is this OK?",
vbYesNo) = vbYes Then
For Each ctl In frm.Controls
With ctl
Select Case .ControlType
Case acTextBox
If Forms!fIndepConcomMeds!record_monitored <> 0 Then
ctl.Locked = LockValue
Else
ctl.Locked = False
End If
Case acComboBox
If Forms!fIndepConcomMeds!record_monitored <> 0 Then
ctl.Locked = LockValue
Else
ctl.Locked = False
End If
Case acListBox
If Forms!fIndepConcomMeds!record_monitored <> 0 Then
ctl.Locked = LockValue
Else
ctl.Locked = False
End If
Case acCheckBox
If Forms!fIndepConcomMeds!record_monitored <> 0 Then
ctl.Locked = LockValue
Else
ctl.Locked = False
End If
Case acToggleButton
If Forms!fIndepConcomMeds!record_monitored <> 0 Then
ctl.Locked = LockValue
Else
ctl.Locked = False
End If
Case acCommandButton
If Forms!fIndepConcomMeds!record_monitored <> 0 Then
ctl.Locked = LockValue
Else
ctl.Locked = False
End If
Case acSubform
If Forms!fIndepConcomMeds!record_monitored <> 0 Then
ctl.Locked = LockValue
Else
ctl.Locked = False
End If
Case acOptionGroup
If Forms!fIndepConcomMeds!record_monitored <> 0 Then
ctl.Locked = LockValue
Else
ctl.Locked = False
End If
Case acOptionButton
If Forms!fIndepConcomMeds!record_monitored <> 0 Then
ctl.Locked = LockValue
Else
ctl.Locked = False
End If
End Select
End With
Next ctl
Set ctl = Nothing
Set frm = Nothing
'End If
End Sub
When I get to the ' Select Case .ControlType' line using the Debugger, it
immediately skips all the way down to 'End Select', and soon then to 'End
Sub', so none of the controls in the current record are locked.
Why is it skipping directly to the 'End Select'? I do have similar code in
the Form's 'On Current' Event as well, and am not sure if this is interfering.
Thank you.