View Full Version : Enabling additional fields based on selection


Himy
01-11-2002, 04:17 AM
I have a data entry form, with 30 odd fields in it. One of the fields has a combo box with three available selections. Depending on the Selection in this combo box - I want to "Enable" two other combo boxes for addition information. These are set to disabled as default...
All information is to be stored in the one table.

How do I do it?

Thanks for oyur help,
Himy

David R
01-11-2002, 07:42 AM
Here's some code I used for this same purpose. It's based off a query connecting two tables, but the theory is the same:


Private Sub Form_Current()
Dim blnVisEnabled As Boolean

If Me.DeviceName = "Car Club" Then
blnVisEnabled = True
Else
blnVisEnabled = False
End If

Me.LicPlate.Enabled = blnVisEnabled
Me.VehYear.Enabled = blnVisEnabled
Me.VehModel.Enabled = blnVisEnabled

End Sub


HTH,
David R

Himy
01-13-2002, 07:38 PM
Hi David thanks for that, although it doesn't work still!! here's what I have, if I can explain in a little more detail...

The error message I'm getting is this:

http://www.maton.com.au/testimages/access1.jpg

The code I am assigning is this - it seems to check out no probs and is almost identical to 3 or 4 other codes people have shown me:

http://www.maton.com.au/testimages/access2.jpg

The form and code assignment looks like this, comboboxes I've labelled in red...

http://www.maton.com.au/testimages/access3.gif

Hope someone can help me!!!!

Cheers,

Himy

Himy
01-13-2002, 09:19 PM
OK I fixed it, and just for anyone else who has the same problem, it worked when I changed the BeforeUpdate event procedure name to

=[Form_Current] instead of =Form_Current()

Cheers,

Himy

David R
01-14-2002, 03:01 PM
Errr...huh? Form_Current is an event, not a field. I'm not sure why that worked, and doubly-unsure why you're calling it from BeforeUpdate. If you don't understand the order in which events fire, you could lock yourself into some nasty loops.

The code I posted above is linked to [Event Procedure] in the Properties> Event>On Current event of my subform. It has to be called Private Sub Form_Current() (to my knowledge) in order for Access to know to set it off. I don't have anything in the BeforeUpdate event, and it makes them active/inactive immediately upon changing the value.

HTH,
David R