After update disabling controls

D

dougal

Hi,

I'm a total access novice and would really appreciate some help with this. I
have a combo box which has three choices; Yes, No and Don't Know. Depending
on the choice I want other combo boxes to remain disabled or become enabled.
I have managed it so that combo B becomes active when combo A = "Yes" and
plan to replicate this for the others ..

Private Sub ComboA_AfterUpdate()
If Me.ComboA= "Yes" Then
Me.ComboB.Enabled = True
Me.ComboC.Enabled = False
Me.ComboD.Enabled = False
Me.TextA.Enabled = False
Else
Me.ComboB.Enabled = False
Me.ComboC.Enabled = True
Me.ComboD.Enabled = False
Me.TextA.Enabled = False
End If

End Sub

My problem comes when I move between records - the fields are displayed as
being enabled or disabled depending on the current record although the fields
do display their correct selection.

Any help would be muchly appreciated!
 
R

Rick Brandt

dougal said:
Hi,

I'm a total access novice and would really appreciate some help with
this. I have a combo box which has three choices; Yes, No and Don't
Know. Depending on the choice I want other combo boxes to remain
disabled or become enabled. I have managed it so that combo B becomes
active when combo A = "Yes" and plan to replicate this for the
others ..

Private Sub ComboA_AfterUpdate()
If Me.ComboA= "Yes" Then
Me.ComboB.Enabled = True
Me.ComboC.Enabled = False
Me.ComboD.Enabled = False
Me.TextA.Enabled = False
Else
Me.ComboB.Enabled = False
Me.ComboC.Enabled = True
Me.ComboD.Enabled = False
Me.TextA.Enabled = False
End If

End Sub

My problem comes when I move between records - the fields are
displayed as being enabled or disabled depending on the current
record although the fields do display their correct selection.

Any help would be muchly appreciated!

Repeat (or call) your code in the Current event of the form. That fires
when you change records.
 
L

Linq Adams via AccessMonster.com

I'm confused!

"the fields are displayed as being enabled or disabled depending on the
current record although the fields do display their correct selection."

Did you mean to say that the "are NOT displayed as being enabled or disabled
depending on the current record?"

Anytime you do formatting in the AfterUpdate event of a control, such as
enabling/disabling your comboboxes, in order to have the formatting persist,

1) The control of the AfterUpdate event has to be bound to a field in the
table

2) You have to include the same code in the form's OnCurrent event
 
D

dougal

Sorry, what I meant was that the fields being displayed depending on the most
recent entry.

I've checked and the code is also present in the OnCurrent event on the Form
although I didn't actually put it there (is that right?) and the control is
also bound to the only column in the combo box and yet it still doesn't work!
 

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