Can a field be inactive until another field is selected in Access

F

favellok

I'm using an Access database. Let's say I have a field that the user can
choose from three different departments. If they choose department "a", I
want another field to become active that would require input. If they choose
department "B" or "C", the additional input is not needed. Is it possible to
have a field inactive until a choice has been made in another field?
 
S

Stefan Hoffmann

hi,
I'm using an Access database. Let's say I have a field that the user can
choose from three different departments. If they choose department "a", I
want another field to become active that would require input. If they choose
department "B" or "C", the additional input is not needed. Is it possible to
have a field inactive until a choice has been made in another field?
Use the Change event:

Private Sub Text0_Change()

OtherControl.Enabled = (Nz(Text0.Value, "") = "a")

End Sub



mfG
--> stefan <--
 
K

Ken Sheridan

You can do it in a form by putting the following code in the form's Current
event procedure:

If Me.[Department] = "A")
Me.[TheOtherControl].Enabled = True
Else
Me.[TheOtherControl].Enabled = False
End If

and this in the Department control's AfterUpdate event procedure:

If Me.[Department] = "A")
Me.[TheOtherControl].Enabled = True
Else
Me.[TheOtherControl] = Null
Me.[TheOtherControl].Enabled = False
End If

The difference is that the second, as well as enabling/disabling the other
control, also sets it to Null, i.e. removes any existing value, if the user
changes Department from "A" to something else.

Ken Sheridan
Stafford, England
 

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