Disabling text box in form contingent on criteria

J

Jack Sheet

Hi all
Access 97

This sounds like a fairly standard sort of thing to do, but I am stuck.

I want a text box in a form (to update a field in a table) to be enabled or
disabled for editing depending on the value of another field within the same
record.

Eg: if ClientType field is "Company" then I want a yes/no box tied to field
"PLC" to be enabled to tick, but if the ClientType field is anything else I
want the PLC checkbox to be disabled and greyed out.

There are two problems. I expect that should be fairly easy (albeit
currently beyond my capabilities) to have the enabling/disabling updated
when amendments to the record are saved, so that when next opening the
record the field will be enabled or not. However, ideally (and I suspect
more difficult to achieve) I would like the field to be enabled or disabled
instantanously when the ClientType field is amended. I can live without
this ideal if I have to.

Thanks for any help.
 
J

John Spencer

You don't enable/disable fields. You enable/disable controls.

I would put code in two places. The form's current event and the ClientType
control's afterupdate event.

If Me.ClientType & vbNullstring = "Company" Then
Me.PLC.Enabled = True
Else
Me.PLC.Enabled = False
End If
 

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