Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Based value of a field from another field

Status
Not open for further replies.

jh3016

Programmer
Jun 6, 2003
148
US
I have an Access database that has a checkbox. When that checkbox is checked, I would like to put the word "Purple" in the field "Color". However, if the checkbox is not checked, I would like to be able to type whatever color I wanted to. Is this possible?

Fields:
Dryclean Yes/No
Color

Thanks in advance.
 
Do you want this to happen on the form during data entry?

You'll probably have write a bit of code to do this, but it is definitely possible.

In the AfterUpdate event of your Dryclean checkbox you could do something like this:


If me.Dryclean then
me.color.value = "Purple"
me.color.locked = true
'Lock the color textbox to prevent the user
'from changing the color - only necessary if you don't
'want to allow the user you change the color from purple.

Else
me.color.setfocus
'Changes the focus to your color textbox
'to allow the user to input color

end if


Ensure that the names i put in red text are the names of your CheckBox and TextBox respectively.

Alec Doughty
Doughty Consulting P/L

"Life's a competition. Play hard, but play fair"
 
Thanks, this worked partially. It does put "purple" in the box when the Yes/No is checked. However, if you uncheck the box and try to put "red" in the color, it does not allow you to do this.

Is there something I'm missing?

Thanks again.
 
put the line
me.color.locked = false

right after the else line and before the setfocus.

sorry, I left that bit out.

Alec Doughty
Doughty Consulting P/L

"Life's a competition. Play hard, but play fair"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top