Hi All
I have a form with about 50 Check boxes on it. These are used to indicate which of the forms within a survey db have been completed, and which still need to be completed by the user. What I am trying to do is display the check box's label in red if the indicated form has not been completed (checkbox value = 0).
I've tried adapting this code from the on-line help, but it errors out on the line indicated. I've tried declaring the ctlLabelName variable as a Control and get an error "Object Variable or With Block variable not set". If I use the Set keyword, I get the error message "Object required".
The code is called by the form's Open event. because it is an advisory form, all the controls are Locked so that the user has to go back to the relevent form to make any changes.
*****
Can someone show me what I am doing wrong?
Thanks in advance
Lightning
I have a form with about 50 Check boxes on it. These are used to indicate which of the forms within a survey db have been completed, and which still need to be completed by the user. What I am trying to do is display the check box's label in red if the indicated form has not been completed (checkbox value = 0).
I've tried adapting this code from the on-line help, but it errors out on the line indicated. I've tried declaring the ctlLabelName variable as a Control and get an error "Object Variable or With Block variable not set". If I use the Set keyword, I get the error message "Object required".
The code is called by the form's Open event. because it is an advisory form, all the controls are Locked so that the user has to go back to the relevent form to make any changes.
*****
Code:
Sub SetCheckBoxProperties(frm As Form)
Dim ctl As Control
Dim ctlLabelName As Control
' Enumerate Controls collection.
For Each ctl In frm.Controls
' Check to see if control is check box.
If ctl.ControlType = acCheckBox Then
If ctl.Value = 0 Then
Set ctlLabelName = "lbl" & ctl.Name 'This line gives the error
ctlLabelName.BackColor = 255
ctlLabelName.ForeColor = 16777215
End If
End If
Next ctl
End Sub
Can someone show me what I am doing wrong?
Thanks in advance
Lightning