Prevent change to field based on value selected in drop down

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

Guest

I have a form that has a field that is a drop down with 5 values in it. Is
it possible to lock the field from update if they select one of the values,
but leave it open for update if they select the other 4?
Ex:
Values: Plan, Hold, Request, In process, Cancel

If Request is selected I do not want the users to be able to change the
status, but if they select Plan - then it is ok to have the user change the
status
 
Patricia,

In the AfterUpdate event of the combo box and the form's OnCurrent event:

If Me![YourComboBox] = "Request" Then
Me![YourComboBox].Locked = True
End If

Note that, depending on your RowSource and ColumnWidths properties, the
combo box may *display* something different from its value. If you're unsure
what the value is corresponding to "Request", insert a temporary MsgBox
statement in the procedure:

MsgBox Me![YourComboBox]

then edit the If statement as required.

Sprinks
 
Patricia,
Use the AfterUpdate event of the combo to lock the field.
Private Sub YourComboName_AfterUpdate()
If YourComboName = "Request" Then
YourComboName.Locked = True
YourComboName.Enabled = False
Else
YourComboName.Locked = False
YourComboName.Enabled = True
End If

You'll also have to place this same code on the OnCurrent event of the
form itself... so that whenever you browse to a "Request" record, the field
will be Locked.
------
HTH
Al Campagna
Access MVP 2007
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love, and you'll never work a day in your life."
 

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

Back
Top