Hiding Control BAsed on Check Box

  • Thread starter Thread starter Nigel
  • Start date Start date
N

Nigel

I have a check box control on a form, "Complaint", which when unchecked I
want the ComplaintClosed memo control greyed out. If Complaint is checked I
then want the ComplaintClosed control to be visible and a message box to
display. I have used the following code, but the ComplaintClosed control will
only do as it should when I go to another recoed and then return to the
current record. Any help would be greatly appreciated.

Private Sub Form_Current()
If Me!Complaint = 0 Then
Me!ComplaintClosed.Enabled = False
Else
Me!ComplaintClosed.Enabled = True
MsgBox "Complaint against this person"
End If
End Sub

Thanks

Nigel
 
Nigel said:
I have a check box control on a form, "Complaint", which when unchecked I
want the ComplaintClosed memo control greyed out. If Complaint is checked
I
then want the ComplaintClosed control to be visible and a message box to
display. I have used the following code, but the ComplaintClosed control
will
only do as it should when I go to another recoed and then return to the
current record. Any help would be greatly appreciated.

Private Sub Form_Current()
If Me!Complaint = 0 Then
Me!ComplaintClosed.Enabled = False
Else
Me!ComplaintClosed.Enabled = True
MsgBox "Complaint against this person"
End If
End Sub

Thanks

Nigel

Put the code in the check box's After Update event. You might also want to
include Me.Dirty=False in there too to save the record.

Keith.
www.keithwilby.co.uk
 
Include this code in the AfterUpdate event of the checkbox control as well.
This way it will fire both when changing records and when the control itself
is changed.

--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)
 
Many thanks, worked a treat!

Jack Leach said:
Include this code in the AfterUpdate event of the checkbox control as well.
This way it will fire both when changing records and when the control itself
is changed.

--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)
 
Back
Top