Lock Combo Box

B

Bob V

My Combo Box cbOwner , I would like to lock it after making a selection ,
entering data into it, so if I want to change my selection I will have to
delete that record, Is there something I can put in my AfterUpdate?
Thanks for any Help..Bob
 
K

Ken Snell \(MVP\)

You can lock the combo box in the AfterUpdate event:

Private Sub ComboBoxName_AfterUpdate()
If Len(Me.ComboBoxName.Value & "") > 0 Then
Me.ComboBoxName.Locked = True
End If
End Sub


If you're using a continuous forms view, this will lock the combo box in
each record, not just in the current record. You'd need to include code in
the form's Current event to unlock the combo box for a new record, and to
lock it again for an existing record:

Private Sub Form_Current()
Call ComboBoxName_AfterUpdate()
End Sub

Note that the above code also will be desirable if you have a single forms
view, as it will unlock the combo box for a new record and relock it for an
existing record.
 
K

Karl

Hello,

I am in a similar position. I have a time database where employees select
the day of the year from the main form. I then have a subform with a combo
box (EmployeeID) where the employee picks there name from the list in the
combo box. There is then a subform in the employee subform where employees
enter there time. I want a similar situation where once an employee's name
is selected from the combo box I want it to lock that employee name in and
can only be changed by deleting the record. I entered the after update code
you suggested and it works fine, however the on current code does not seem to
work as I can't select another employee record for the same day or any other
day for that matter. Does this code belong on the On current of the employee
subform or on the date main form?

thanks.
 
Top