Using the AfterUpdate event

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have been trying to figure out how to use the afterupdate function and I
need some help.

In a form I have a combobox and I want to lock the value in the box once the
user has entered/chosen a value - how do I do that???? I can see I need to
use the afterupdate function but I can't figure out how to do it.

Thanks for your help!
 
Bettina, You can't lock a control that has the focus, so you need to set focus to a different
control on your form first:

Private Sub mvCombo_AfterUpdate()
Me.someothercontrol.setfocus
Me.myCombo.Locked = True
End Sub

Keep in mind that should the user accidently make the wrong selection they will not be able to
change it once the combo is locked.

Hope this helps!
 
Thanks, it did help - if it causes too much trouble for my users I will
create a new form for entering data where the combobox isn't locked (and a
seach form where it is locked).

Thanks again!

Bettina

"Reggie" skrev:
 
-----Original Message-----
I would suggest leaving it unlocked with the AfterUpdate
event so that the user could rectify a mistake should
they discover one.

However, in the form's Current event, I'd put a bit of
code that determines whether this is a new record being
entered or an old record being viewed.

i.e.

Private Sub Form_Current()
Me.MyTextBox.Enabled = Me.NewRecord
End Sub
 
-----Original Message
In addition to what I said on the current event, you want
to extend it like so:

Private Sub Form_Current()
Me.MyTextBox.Enabled = Me.NewRecord
Me.MyTextBox.Locked = Not Me.NewRecord
End Sub
 
Back
Top