Restrict entry in field

V

vladi16

Combo Box #1 is "Result" and has two choices: Pass and Fail.
Combo Box #2 is "Action Taken" and has three choices: Verbal Counseling,
Written Reprimand, and Discipline.

I would like the Action Taken field to remain blanked or grayed out unless
someone chooses Fail in the Result field.

I am just not really sure how to go about doing this. I appreciate any help
someone might give.

vladi
 
A

Al Campagna

vladi16,
Set ActionTaken to Disabled as a default.
Use the AfterUpdate event of Result...

Private Sub Result_AfterUpdate()
ActionTaken.Enabled = Result = "Fail"
End Sub

You'll also need the same code in the OnCurrent event of the form
itself, so... as you browse from record to record, ActionTaken will
Enable/Disable accordingly.

Private Sub Form_Current()
ActionTaken.Enabled = Result = "Fail"
End Sub
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

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

Allen Browne

Use a Validation Rule on the table where this data is stored.

1. Open your table in design view.
2. Open the Properties box.
3. Beside the Validation Rule in the properties box, enter:
([Action Taken] Is Null) OR ([Result] = "Fail")
4. Save. (Answer No if you don't want it to test existing data.)

Be sure to use the Validation Rule in the properties box, not the one in the
lower pane of table design (which relates to one field only.)

There are 2 ways to satisfy this rule:
a) If the Action Taken field is blank it's happy.
b) If teh Result field read Fail, it's happy (even if the other one is
filled in.)

More info about validation rules:
http://allenbrowne.com/ValidationRule.html
 
V

vladi16

Most of this I think I get, except the first part. Can you elaborate on
exactly how to disable the field?
 
V

vladi16

Disregard my previous post... I figured it out.

However, when I copied the code into the form's OnCurrent I get an error.

Any thoughts? Thanks.
 

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