enable field based on value of another

G

Guest

I have created a form in access 2003. It is a merit increase form. I have one
field, text1, that is a lookup (combo box) based a table (tblperformance)
which list the performance rating (distinguidhed, adequate, etc). Also I have
several merit increase fields, text2, text3... When a performance rating is
chosen I want to enabled the corresponding text box for data entry. Any
suggestions as to how i should set this up. Thanks
 
G

Guest

Private Sub Combo0_AfterUpdate()
Select Case Combo0.Value
Case "a"
Text2.Enabled = True
Text4.Enabled = False
Text6.Enabled = False
Text8.Enabled = False
Case "b"
Text2.Enabled = False
Text4.Enabled = True
Text6.Enabled = False
Text8.Enabled = False
Case "c"
Text2.Enabled = False
Text4.Enabled = False
Text6.Enabled = True
Text8.Enabled = False
Case Else
Text2.Enabled = False
Text4.Enabled = False
Text6.Enabled = True
Text8.Enabled = False
End Select

End Sub
 
G

Guest

Thanks a million ES for your help, but there is one problem that I
encountered. I am not sure what I did wrong, but after a choiuce is made and
the proper field is activated that field is activated for each subquent
record for that particular employee. So if last year an employee recieved an
adequate rating I make the selection. Then say this year the same person has
a distinguished rating the previous record's field enabled property is
changed dispite the fact that adequate is the choice in the combo box. Here's
my select case statement:

Private Sub performancelevel_AfterUpdate()
Select Case performancelevel.Value
Case "5"
Q_1_5.Enabled = True
Q_1_4.Enabled = False
Q_1_3.Enabled = False
Q_1_2.Enabled = False
Q_1_1.Enabled = False
Case "4"
Q_1_5.Enabled = False
Q_1_4.Enabled = True
Q_1_3.Enabled = False
Q_1_2.Enabled = False
Q_1_1.Enabled = False
Case "3"
Q_1_5.Enabled = False
Q_1_4.Enabled = False
Q_1_3.Enabled = True
Q_1_2.Enabled = False
Q_1_1.Enabled = False
Case "2"
Q_1_5.Enabled = False
Q_1_4.Enabled = False
Q_1_3.Enabled = False
Q_1_2.Enabled = True
Q_1_1.Enabled = False
Case "1"
Q_1_5.Enabled = False
Q_1_4.Enabled = False
Q_1_3.Enabled = False
Q_1_2.Enabled = False
Q_1_1.Enabled = True
End Select
Where did I go wrong? Thanks


-
tm
 
R

Ron2006

Thanks a million ES for your help, but there is one problem that I
encountered. I am not sure what I did wrong, but after a choiuce is made and
the proper field is activated that field is activated for each subquent
record for that particular employee. So if last year an employee recieved an
adequate rating I make the selection. Then say this year the same person has
a distinguished rating the previous record's field enabled property is
changed dispite the fact that adequate is the choice in the combo box. Here's
my select case statement:

Private Sub performancelevel_AfterUpdate()
Select Case performancelevel.Value
Case "5"
Q_1_5.Enabled = True
Q_1_4.Enabled = False
Q_1_3.Enabled = False
Q_1_2.Enabled = False
Q_1_1.Enabled = False
Case "4"
Q_1_5.Enabled = False
Q_1_4.Enabled = True
Q_1_3.Enabled = False
Q_1_2.Enabled = False
Q_1_1.Enabled = False
Case "3"
Q_1_5.Enabled = False
Q_1_4.Enabled = False
Q_1_3.Enabled = True
Q_1_2.Enabled = False
Q_1_1.Enabled = False
Case "2"
Q_1_5.Enabled = False
Q_1_4.Enabled = False
Q_1_3.Enabled = False
Q_1_2.Enabled = True
Q_1_1.Enabled = False
Case "1"
Q_1_5.Enabled = False
Q_1_4.Enabled = False
Q_1_3.Enabled = False
Q_1_2.Enabled = False
Q_1_1.Enabled = True
End Select
Where did I go wrong? Thanks

-
tm






- Show quoted text -

It sounds as if you are working with a datasheet view and what you are
doing will showup like that.

Have you looked at conditional formating - which will work on each row
independently.

for instance:
Default the enabled property to true on All of the fields.
In the conditional format for text6 (for instance) change the testtype
to "Expression" then enter test as
not [Combo0] = "D"
and then chose the formating for not enabled - the last picture
over on the right side.

The test will change for each of the separate fields.

Ron
 
G

Guest

Hi Ron:
I don't quite understand your suggestion. In test6 for example how do I
change the testtype? Am I doing this in the properties for text6? not [combo0
= "D" is also confusing to me. I'm a novice so it's all very confusing. If
you could be a little more specific that might help me with my limited
knowledge. Thanks
--
tm


Ron2006 said:
Thanks a million ES for your help, but there is one problem that I
encountered. I am not sure what I did wrong, but after a choiuce is made and
the proper field is activated that field is activated for each subquent
record for that particular employee. So if last year an employee recieved an
adequate rating I make the selection. Then say this year the same person has
a distinguished rating the previous record's field enabled property is
changed dispite the fact that adequate is the choice in the combo box. Here's
my select case statement:

Private Sub performancelevel_AfterUpdate()
Select Case performancelevel.Value
Case "5"
Q_1_5.Enabled = True
Q_1_4.Enabled = False
Q_1_3.Enabled = False
Q_1_2.Enabled = False
Q_1_1.Enabled = False
Case "4"
Q_1_5.Enabled = False
Q_1_4.Enabled = True
Q_1_3.Enabled = False
Q_1_2.Enabled = False
Q_1_1.Enabled = False
Case "3"
Q_1_5.Enabled = False
Q_1_4.Enabled = False
Q_1_3.Enabled = True
Q_1_2.Enabled = False
Q_1_1.Enabled = False
Case "2"
Q_1_5.Enabled = False
Q_1_4.Enabled = False
Q_1_3.Enabled = False
Q_1_2.Enabled = True
Q_1_1.Enabled = False
Case "1"
Q_1_5.Enabled = False
Q_1_4.Enabled = False
Q_1_3.Enabled = False
Q_1_2.Enabled = False
Q_1_1.Enabled = True
End Select
Where did I go wrong? Thanks

-
tm






- Show quoted text -

It sounds as if you are working with a datasheet view and what you are
doing will showup like that.

Have you looked at conditional formating - which will work on each row
independently.

for instance:
Default the enabled property to true on All of the fields.
In the conditional format for text6 (for instance) change the testtype
to "Expression" then enter test as
not [Combo0] = "D"
and then chose the formating for not enabled - the last picture
over on the right side.

The test will change for each of the separate fields.

Ron
 
R

Ron2006

Hi Ron:
I don't quite understand your suggestion. In test6 for example how do I
change the testtype? Am I doing this in the properties for text6? not [combo0
= "D" is also confusing to me. I'm a novice so it's all very confusing. If
you could be a little more specific that might help me with my limited
knowledge. Thanks
--
tm



It sounds as if you are working with a datasheet view and what you are
doing will showup like that.
Have you looked at conditional formating - which will work on each row
independently.
for instance:
Default the enabled property to true on All of the fields.
In the conditional format for text6 (for instance) change the testtype
to "Expression" then enter test as
not [Combo0] = "D"
and then chose the formating for not enabled - the last picture
over on the right side.
The test will change for each of the separate fields.
Ron- Hide quoted text -

- Show quoted text -

Talibm,

I'll explain ( and besides that I think I made the test wrong. But
here goes)

First off make sure that the default value for all of the fields
involved is NOT set to enabled=false.
comment out the code that you put in before.

1) Open the form in design view.
2) Select field "Q_1_1"
3) Right mouse click the field and go down and select "Conditional
formating"
4) In the window that comes up for Condition 1
The first dropdown shows "Field Value is". Activate the
dropdown and select "Expression is"
5) Go to the next field in this formating window and it is there that
we will write the expression. Assuming that the name of your combo box
is "performancelevel" we will write:
not [performancelevel] = "1"
6) Now look at the things that you can modify / set the properties to.
The little picture on the far right is the enable button. If you put
your mouse over it it will say "enable". Click it once and the example
box to the left will go gray. That means that the field property will
be set to enabled = false.
7) Mouse the OK button

The condition that we just set says that the field "Q_1_1" will be
disabled IF the value in [performancelevel] is not = 1.
If [performancelevel] is a numeric field then I do not believe that
you need the quotes around the 1.

Now go to field "Q_1_2" and do everything the same except that the
test here will be not
[performancelevel] = "2"

And so on for each of the other fields.

Hope this helps.

Ron
 
R

Ron2006

Hi Ron:
I don't quite understand your suggestion. In test6 for example how do I
change the testtype? Am I doing this in the properties for text6? not [combo0
= "D" is also confusing to me. I'm a novice so it's all very confusing. If
you could be a little more specific that might help me with my limited
knowledge. Thanks
Ron2006 said:
Thanks a million ES for your help, but there is one problem that I
encountered. I am not sure what I did wrong, but after a choiuce is made and
the proper field is activated that field is activated for each subquent
record for that particular employee. So if last year an employee recieved an
adequate rating I make the selection. Then say this year the same person has
a distinguished rating the previous record's field enabled property is
changed dispite the fact that adequate is the choice in the combo box. Here's
my select case statement:
Private Sub performancelevel_AfterUpdate()
Select Case performancelevel.Value
Case "5"
Q_1_5.Enabled = True
Q_1_4.Enabled = False
Q_1_3.Enabled = False
Q_1_2.Enabled = False
Q_1_1.Enabled = False
Case "4"
Q_1_5.Enabled = False
Q_1_4.Enabled = True
Q_1_3.Enabled = False
Q_1_2.Enabled = False
Q_1_1.Enabled = False
Case "3"
Q_1_5.Enabled = False
Q_1_4.Enabled = False
Q_1_3.Enabled = True
Q_1_2.Enabled = False
Q_1_1.Enabled = False
Case "2"
Q_1_5.Enabled = False
Q_1_4.Enabled = False
Q_1_3.Enabled = False
Q_1_2.Enabled = True
Q_1_1.Enabled = False
Case "1"
Q_1_5.Enabled = False
Q_1_4.Enabled = False
Q_1_3.Enabled = False
Q_1_2.Enabled = False
Q_1_1.Enabled = True
End Select
Where did I go wrong? Thanks
-
tm
:
Private Sub Combo0_AfterUpdate()
Select Case Combo0.Value
Case "a"
Text2.Enabled = True
Text4.Enabled = False
Text6.Enabled = False
Text8.Enabled = False
Case "b"
Text2.Enabled = False
Text4.Enabled = True
Text6.Enabled = False
Text8.Enabled = False
Case "c"
Text2.Enabled = False
Text4.Enabled = False
Text6.Enabled = True
Text8.Enabled = False
Case Else
Text2.Enabled = False
Text4.Enabled = False
Text6.Enabled = True
Text8.Enabled = False
End Select
End Sub- Hide quoted text -
- Show quoted text -
It sounds as if you are working with a datasheet view and what you are
doing will showup like that.
Have you looked at conditional formating - which will work on each row
independently.
for instance:
Default the enabled property to true on All of the fields.
In the conditional format for text6 (for instance) change the testtype
to "Expression" then enter test as
not [Combo0] = "D"
and then chose the formating for not enabled - the last picture
over on the right side.
The test will change for each of the separate fields.
Ron- Hide quoted text -
- Show quoted text -

Talibm,

I'll explain ( and besides that I think I made the test wrong. But
here goes)

First off make sure that the default value for all of the fields
involved is NOT set to enabled=false.
comment out the code that you put in before.

1) Open the form in design view.
2) Select field "Q_1_1"
3) Right mouse click the field and go down and select "Conditional
formating"
4) In the window that comes up for Condition 1
The first dropdown shows "Field Value is". Activate the
dropdown and select "Expression is"
5) Go to the next field in this formating window and it is there that
we will write the expression. Assuming that the name of your combo box
is "performancelevel" we will write:
not [performancelevel] = "1"
6) Now look at the things that you can modify / set the properties to.
The little picture on the far right is the enable button. If you put
your mouse over it it will say "enable". Click it once and the example
box to the left will go gray. That means that the field property will
be set to enabled = false.
7) Mouse the OK button

The condition that we just set says that the field "Q_1_1" will be
disabled IF the value in [performancelevel] is not = 1.
If [performancelevel] is a numeric field then I do not believe that
you need the quotes around the 1.

Now go to field "Q_1_2" and do everything the same except that the
test here will be not
[performancelevel] = "2"

And so on for each of the other fields.

Hope this helps.

Ron- Hide quoted text -

- Show quoted text -

Another footnote............

If you make a mistake in writing the expression, nothing will tell you
that. However the conditional formating will NOT work either. So if it
does not work it is an indication that something is wrong with the
expression.

Ron
 
G

Guest

Thanks Ron. This is work great!
--
tm


Ron2006 said:
Hi Ron:
I don't quite understand your suggestion. In test6 for example how do I
change the testtype? Am I doing this in the properties for text6? not [combo0
= "D" is also confusing to me. I'm a novice so it's all very confusing. If
you could be a little more specific that might help me with my limited
knowledge. Thanks
:
Thanks a million ES for your help, but there is one problem that I
encountered. I am not sure what I did wrong, but after a choiuce is made and
the proper field is activated that field is activated for each subquent
record for that particular employee. So if last year an employee recieved an
adequate rating I make the selection. Then say this year the same person has
a distinguished rating the previous record's field enabled property is
changed dispite the fact that adequate is the choice in the combo box. Here's
my select case statement:
Private Sub performancelevel_AfterUpdate()
Select Case performancelevel.Value
Case "5"
Q_1_5.Enabled = True
Q_1_4.Enabled = False
Q_1_3.Enabled = False
Q_1_2.Enabled = False
Q_1_1.Enabled = False
Case "4"
Q_1_5.Enabled = False
Q_1_4.Enabled = True
Q_1_3.Enabled = False
Q_1_2.Enabled = False
Q_1_1.Enabled = False
Case "3"
Q_1_5.Enabled = False
Q_1_4.Enabled = False
Q_1_3.Enabled = True
Q_1_2.Enabled = False
Q_1_1.Enabled = False
Case "2"
Q_1_5.Enabled = False
Q_1_4.Enabled = False
Q_1_3.Enabled = False
Q_1_2.Enabled = True
Q_1_1.Enabled = False
Case "1"
Q_1_5.Enabled = False
Q_1_4.Enabled = False
Q_1_3.Enabled = False
Q_1_2.Enabled = False
Q_1_1.Enabled = True
End Select
Where did I go wrong? Thanks

:
Private Sub Combo0_AfterUpdate()
Select Case Combo0.Value
Case "a"
Text2.Enabled = True
Text4.Enabled = False
Text6.Enabled = False
Text8.Enabled = False
Case "b"
Text2.Enabled = False
Text4.Enabled = True
Text6.Enabled = False
Text8.Enabled = False
Case "c"
Text2.Enabled = False
Text4.Enabled = False
Text6.Enabled = True
Text8.Enabled = False
Case Else
Text2.Enabled = False
Text4.Enabled = False
Text6.Enabled = True
Text8.Enabled = False
End Select
End Sub- Hide quoted text -
- Show quoted text -
It sounds as if you are working with a datasheet view and what you are
doing will showup like that.
Have you looked at conditional formating - which will work on each row
independently.
for instance:
Default the enabled property to true on All of the fields.
In the conditional format for text6 (for instance) change the testtype
to "Expression" then enter test as
not [Combo0] = "D"
and then chose the formating for not enabled - the last picture
over on the right side.
The test will change for each of the separate fields.
Ron- Hide quoted text -
- Show quoted text -

Talibm,

I'll explain ( and besides that I think I made the test wrong. But
here goes)

First off make sure that the default value for all of the fields
involved is NOT set to enabled=false.
comment out the code that you put in before.

1) Open the form in design view.
2) Select field "Q_1_1"
3) Right mouse click the field and go down and select "Conditional
formating"
4) In the window that comes up for Condition 1
The first dropdown shows "Field Value is". Activate the
dropdown and select "Expression is"
5) Go to the next field in this formating window and it is there that
we will write the expression. Assuming that the name of your combo box
is "performancelevel" we will write:
not [performancelevel] = "1"
6) Now look at the things that you can modify / set the properties to.
The little picture on the far right is the enable button. If you put
your mouse over it it will say "enable". Click it once and the example
box to the left will go gray. That means that the field property will
be set to enabled = false.
7) Mouse the OK button

The condition that we just set says that the field "Q_1_1" will be
disabled IF the value in [performancelevel] is not = 1.
If [performancelevel] is a numeric field then I do not believe that
you need the quotes around the 1.

Now go to field "Q_1_2" and do everything the same except that the
test here will be not
[performancelevel] = "2"

And so on for each of the other fields.

Hope this helps.

Ron- Hide quoted text -

- Show quoted text -

Another footnote............

If you make a mistake in writing the expression, nothing will tell you
that. However the conditional formating will NOT work either. So if it
does not work it is an indication that something is wrong with the
expression.

Ron
 

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