Hiding Control BAsed on Check Box

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
 
K

Keith Wilby

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
 
J

Jack Leach

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)
 
N

Nigel

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top