drop down field

T

tracktraining

Hi All,

I was wondering if there is a way to code in VB if the drop down field is
selected to be "Terminated", then that field cannot be changed anymore. So,
once the user select "Terminated" from the drop down menu field, then a
message will appear asking if this is what they want, if yes, then
"Terminated" is selected and user is unable to change that field anymore.

Is this possible? any suggestions?

Thanks,
Tracktraining
 
M

Maurice

If you select the option you could go for the "locked" option. This ofcourse
would only apply for the actual form and situation. If you want it to stay
locked you have to add a initial check when the form load to check if the
value is "terminated".

So basically:


in the after update of the control you place

if me.combobox="terminated" then
me.combobox.locked =true
end if

if you have a table as a source you should test for the numerical value..
something like this

if me.combobox=1 then '- if that's the value for terminated
me.combobx.locked=true
end if

Now in the form load (or form open) you can place the check to see if the
value is set to 'terminated' much the same way. But that's only necessary if
you have the option to view all records.

hth
 
T

tracktraining

thanks!
--
Learning


Maurice said:
If you select the option you could go for the "locked" option. This ofcourse
would only apply for the actual form and situation. If you want it to stay
locked you have to add a initial check when the form load to check if the
value is "terminated".

So basically:


in the after update of the control you place

if me.combobox="terminated" then
me.combobox.locked =true
end if

if you have a table as a source you should test for the numerical value..
something like this

if me.combobox=1 then '- if that's the value for terminated
me.combobx.locked=true
end if

Now in the form load (or form open) you can place the check to see if the
value is set to 'terminated' much the same way. But that's only necessary if
you have the option to view all records.

hth
 
D

Dale Fye

Actually, I'd use the Forms Current event rather that Form_Open or
Form_Load.

Basically, you want this code to fire every time you move to a different
record, so that they cannot change the value. However, I would also change
the code you used because the way you did it, if you lock it then when you
go to another record, it will stay locked (because you never set it to
false). So here is what I would do:

Private Sub combobox_AfterUpdate

me.combobox.locked = (me.combobox = "Terminated")

End Sub

Private Sub Form_Current

me.combobox.locked = (me.combobox = "Terminated")

End Sub

Dale
 

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