Locking a combo box

S

Stanley

I set a combo box to enabled yes and locked no and I have no problems picking
a value. My combo box is bound to a table. The problem is I can type over the
value in the combo box and change the value in the table.
I would like to pick a value and subsequently like lock the combo box.
Thanks,
Stanley
 
D

Dennis

Stanly,

If you lock the combo box once the user has entered data, how will they ever
correct it?

Given that, you might try this. I don't know if it will work.

on the field's Got Focus event, add this code:

If inNull(ComboBoxDataFieldNm) then
me.cboCtlNm.Enabled = True
me.cboCtlNm.Locked = False
else
me.cboCtlNm.Enabled = False
me.cboCtlNm.Locked = True
end if

on the field's Lost Focus event, add this code:

me.cboCtlNm.Enabled = True
me.cboCtlNm.Locked = False



I don't know if that will work, I would give it a try.
 
M

Marshall Barton

Stanley said:
I set a combo box to enabled yes and locked no and I have no problems picking
a value. My combo box is bound to a table. The problem is I can type over the
value in the combo box and change the value in the table.
I would like to pick a value and subsequently like lock the combo box.


Use code in the form's AfterUpdate event to lock the combo
box:

Me.thecombobox.Locked = Not IsNull(Me.thecombobox)

What is a user supposed to do if the wrong value was picked?
 
D

Dennis

Marshal,

I'm still learning Access, so please permit a couple of questions from a
student. I understand placing the code you suggested in the form's After
Update event. Here are my questions:

1. What happens when the user goes to enter the next "transaction" during
the same session? The combo box will have been disabled by the Form's After
update so they will not be able to enter anything in the combo box for the
next or subsequent transations in that session.

2. What happens the next time the user enters the form in a different data
entry session and the first thing they pulls up is a prior transations?
Since the Form's After Update has not yet run, they will be able to change
the value in the combo box.

Thanks for the information.
 
D

Douglas J. Steele

Same answer to both questions.

Whatever logic you've got in the AfterUpdate event needs to be invoked in
the form's Current event so that as you move from row to row in the form,
Access determines whether or not the current row needs to have its combo box
locked or not.
 

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