Editable field only based on another field

J

julostarr

Is there a way to make one field only editable based on the answer (like a
Yes/No checkbox) or entry of another field?

For example if you have a Yes/No checkbox and you check No then that makes
another field unavailable to edit, but if you check Yes then that field is
open to edit or instead of a Yes/No it is another data type and you are
required to enter something in order for another field to become editable.
 
J

Jeff Boyce

You could add something like the following to the AfterUpdate event of your
Yes/No checkbox control:

Me!YourOtherField.Enabled = Me!YourCheckbox


Regards

Jeff Boyce
Microsoft Office/Access MVP
 
J

Jeff Boyce

Access is not a "spreadsheet on steroids". You would not add this to a
table, which has no events, but to a form, which does.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
J

julostarr

Well I figured that, but I'm just making sure that there wasn't some way that
I didn't know about. I already tried to put this in a form in the
AfterUpdate in my checkbox control properties. After returning to datasheet
view if I click the checkbox (on or off) I get the following message box:

"The expression After Update you entered as the event property setting
produced the following error: The object doesn't contain the Automation
object 'Benefits.'.

"*The expression may not result in the name of a macro, the name of a
user-defined function, or [Event Procedure].
*There may have been an error evaluating the function, event, or macro."

This is what I put in the After Update field according to your suggestion,
but I used the expression builder in my check box properties window to help
build it:

=Benefits![401(k)%].Enabled=Benefits![401(k)Participant]

Is there something I entered wrong? This also didn't stop the other field
from being editable regardless if the check box was checked or not.
 
J

Jeff Boyce

The error message suggests that Access doesn't have an "automation object"
named "Benefits" ... and I'm pretty sure it doesn't!

Are you trying to refer to a value on a form? If so, check the proper
syntax via Access HELP on 'expressions'. I believe it's something like:

Forms!YourFormName!YourControlName

Regards

Jeff Boyce
Microsoft Office/Access MVP


julostarr said:
Well I figured that, but I'm just making sure that there wasn't some way
that
I didn't know about. I already tried to put this in a form in the
AfterUpdate in my checkbox control properties. After returning to
datasheet
view if I click the checkbox (on or off) I get the following message box:

"The expression After Update you entered as the event property setting
produced the following error: The object doesn't contain the Automation
object 'Benefits.'.

"*The expression may not result in the name of a macro, the name of a
user-defined function, or [Event Procedure].
*There may have been an error evaluating the function, event, or macro."

This is what I put in the After Update field according to your suggestion,
but I used the expression builder in my check box properties window to
help
build it:

=Benefits![401(k)%].Enabled=Benefits![401(k)Participant]

Is there something I entered wrong? This also didn't stop the other field
from being editable regardless if the check box was checked or not.
--
julostarr


Jeff Boyce said:
Access is not a "spreadsheet on steroids". You would not add this to a
table, which has no events, but to a form, which does.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
J

julostarr

I was thinking maybe their might be a conditional expression or IFF function
I could write that would tell my form if mycheckbox was checked yes then
allow editing on another field and if it is checked no then not to allow
editing. I am not sure where to put that or exactly what content to put in
it to construct that expression.
--
julostarr


Jeff Boyce said:
The error message suggests that Access doesn't have an "automation object"
named "Benefits" ... and I'm pretty sure it doesn't!

Are you trying to refer to a value on a form? If so, check the proper
syntax via Access HELP on 'expressions'. I believe it's something like:

Forms!YourFormName!YourControlName

Regards

Jeff Boyce
Microsoft Office/Access MVP


julostarr said:
Well I figured that, but I'm just making sure that there wasn't some way
that
I didn't know about. I already tried to put this in a form in the
AfterUpdate in my checkbox control properties. After returning to
datasheet
view if I click the checkbox (on or off) I get the following message box:

"The expression After Update you entered as the event property setting
produced the following error: The object doesn't contain the Automation
object 'Benefits.'.

"*The expression may not result in the name of a macro, the name of a
user-defined function, or [Event Procedure].
*There may have been an error evaluating the function, event, or macro."

This is what I put in the After Update field according to your suggestion,
but I used the expression builder in my check box properties window to
help
build it:

=Benefits![401(k)%].Enabled=Benefits![401(k)Participant]

Is there something I entered wrong? This also didn't stop the other field
from being editable regardless if the check box was checked or not.
--
julostarr


Jeff Boyce said:
Access is not a "spreadsheet on steroids". You would not add this to a
table, which has no events, but to a form, which does.

Regards

Jeff Boyce
Microsoft Office/Access MVP

Do I use this in the table, a form or query?
--
julostarr


:

You could add something like the following to the AfterUpdate event of
your
Yes/No checkbox control:

Me!YourOtherField.Enabled = Me!YourCheckbox


Regards

Jeff Boyce
Microsoft Office/Access MVP

Is there a way to make one field only editable based on the answer
(like a
Yes/No checkbox) or entry of another field?

For example if you have a Yes/No checkbox and you check No then that
makes
another field unavailable to edit, but if you check Yes then that
field
is
open to edit or instead of a Yes/No it is another data type and you
are
required to enter something in order for another field to become
editable.
 
J

julostarr

Is there a way to build an IIF function that would essentially say for
example that "If [401(k)Participant] = Yes then make this make this
[401(k)Percent] editable else make it uneditable' and add it to the After
Update in the control properties box?
--
julostarr


Jeff Boyce said:
The error message suggests that Access doesn't have an "automation object"
named "Benefits" ... and I'm pretty sure it doesn't!

Are you trying to refer to a value on a form? If so, check the proper
syntax via Access HELP on 'expressions'. I believe it's something like:

Forms!YourFormName!YourControlName

Regards

Jeff Boyce
Microsoft Office/Access MVP


julostarr said:
Well I figured that, but I'm just making sure that there wasn't some way
that
I didn't know about. I already tried to put this in a form in the
AfterUpdate in my checkbox control properties. After returning to
datasheet
view if I click the checkbox (on or off) I get the following message box:

"The expression After Update you entered as the event property setting
produced the following error: The object doesn't contain the Automation
object 'Benefits.'.

"*The expression may not result in the name of a macro, the name of a
user-defined function, or [Event Procedure].
*There may have been an error evaluating the function, event, or macro."

This is what I put in the After Update field according to your suggestion,
but I used the expression builder in my check box properties window to
help
build it:

=Benefits![401(k)%].Enabled=Benefits![401(k)Participant]

Is there something I entered wrong? This also didn't stop the other field
from being editable regardless if the check box was checked or not.
--
julostarr


Jeff Boyce said:
Access is not a "spreadsheet on steroids". You would not add this to a
table, which has no events, but to a form, which does.

Regards

Jeff Boyce
Microsoft Office/Access MVP

Do I use this in the table, a form or query?
--
julostarr


:

You could add something like the following to the AfterUpdate event of
your
Yes/No checkbox control:

Me!YourOtherField.Enabled = Me!YourCheckbox


Regards

Jeff Boyce
Microsoft Office/Access MVP

Is there a way to make one field only editable based on the answer
(like a
Yes/No checkbox) or entry of another field?

For example if you have a Yes/No checkbox and you check No then that
makes
another field unavailable to edit, but if you check Yes then that
field
is
open to edit or instead of a Yes/No it is another data type and you
are
required to enter something in order for another field to become
editable.
 
J

Jeff Boyce

While you might use an IIF() function in a query (or an IF ... THEN...
statement in a function), I don't believe either is necessary.

If I wanted to enable a textbox based on whether a checkbox were checked,
I'd probably add something like the following in the checkbox's AfterUpdate
event:

Me!TextBox.Enabled = Me!Checkbox

Good luck!

Regards

Jeff Boyce
Microsoft Office/Access MVP

julostarr said:
Is there a way to build an IIF function that would essentially say for
example that "If [401(k)Participant] = Yes then make this make this
[401(k)Percent] editable else make it uneditable' and add it to the After
Update in the control properties box?
--
julostarr


Jeff Boyce said:
The error message suggests that Access doesn't have an "automation
object"
named "Benefits" ... and I'm pretty sure it doesn't!

Are you trying to refer to a value on a form? If so, check the proper
syntax via Access HELP on 'expressions'. I believe it's something like:

Forms!YourFormName!YourControlName

Regards

Jeff Boyce
Microsoft Office/Access MVP


julostarr said:
Well I figured that, but I'm just making sure that there wasn't some
way
that
I didn't know about. I already tried to put this in a form in the
AfterUpdate in my checkbox control properties. After returning to
datasheet
view if I click the checkbox (on or off) I get the following message
box:

"The expression After Update you entered as the event property setting
produced the following error: The object doesn't contain the Automation
object 'Benefits.'.

"*The expression may not result in the name of a macro, the name of a
user-defined function, or [Event Procedure].
*There may have been an error evaluating the function, event, or
macro."

This is what I put in the After Update field according to your
suggestion,
but I used the expression builder in my check box properties window to
help
build it:

=Benefits![401(k)%].Enabled=Benefits![401(k)Participant]

Is there something I entered wrong? This also didn't stop the other
field
from being editable regardless if the check box was checked or not.
--
julostarr


:

Access is not a "spreadsheet on steroids". You would not add this to
a
table, which has no events, but to a form, which does.

Regards

Jeff Boyce
Microsoft Office/Access MVP

Do I use this in the table, a form or query?
--
julostarr


:

You could add something like the following to the AfterUpdate event
of
your
Yes/No checkbox control:

Me!YourOtherField.Enabled = Me!YourCheckbox


Regards

Jeff Boyce
Microsoft Office/Access MVP

Is there a way to make one field only editable based on the
answer
(like a
Yes/No checkbox) or entry of another field?

For example if you have a Yes/No checkbox and you check No then
that
makes
another field unavailable to edit, but if you check Yes then that
field
is
open to edit or instead of a Yes/No it is another data type and
you
are
required to enter something in order for another field to become
editable.
 
J

John W. Vinson

If I wanted to enable a textbox based on whether a checkbox were checked,
I'd probably add something like the following in the checkbox's AfterUpdate
event:

Me!TextBox.Enabled = Me!Checkbox

.... and also the Form's Current event, to handle existing records, I'd
suggest.
 
J

julostarr

Can you help me out with understanding this a little more. I entered this:

Me![TextBox].Enabled = Me![Checkbox]

in the After Update under properties of my checkbox control, of course
substituting the TestBox name I wanted to enable for TestBox and the same for
the Checkbox. When I go back to the form view and click the check box I get
an error saying the the Macro doesn't exist. Am I supposed to build a macro
or am I entering something wrong.
 
J

Jeff Boyce

If you entered that directly in the space following the label for
AfterUpdate in the properties, Access will try to find a macro with that
name.

To be more specific, you will need to create an AfterUpdate event procedure
and enter that expression in the event procedure.

Regards

Jeff Boyce
Microsoft Office/Access MVP

julostarr said:
Can you help me out with understanding this a little more. I entered
this:

Me![TextBox].Enabled = Me![Checkbox]

in the After Update under properties of my checkbox control, of course
substituting the TestBox name I wanted to enable for TestBox and the same
for
the Checkbox. When I go back to the form view and click the check box I
get
an error saying the the Macro doesn't exist. Am I supposed to build a
macro
or am I entering something wrong.
--
julostarr


John W. Vinson said:
.... and also the Form's Current event, to handle existing records, I'd
suggest.
 
J

julostarr

Well, I never could get the Me![TextBox].Enabled = Me![Checkbox] to work, but
I played around with an IF Expression and it worked for me. If the checkbox
is checked it goes to the following field to allow editing and if it is
unchecked then the next field is uneditable and tabbing through it skips that
field. The code I used goes as follows:

Private Sub Ctl401_k_Participant_AfterUpdate()
If Me![401(k)Participant] = True Then
Me![401(k)%].Enabled = True
Else
Me![401(k)%].Enabled = False
End If
End Sub

I'm still learning about VBA, but this IF conditional express worked for me
in this situation. I was expecting the field in question to be grayed out
when it was uneditable, but it is fine this way.

If you have any tips for me or can help me understand this a little more
that would be great. If not thank you so much for you help.


--
julostarr


Jeff Boyce said:
If you entered that directly in the space following the label for
AfterUpdate in the properties, Access will try to find a macro with that
name.

To be more specific, you will need to create an AfterUpdate event procedure
and enter that expression in the event procedure.

Regards

Jeff Boyce
Microsoft Office/Access MVP

julostarr said:
Can you help me out with understanding this a little more. I entered
this:

Me![TextBox].Enabled = Me![Checkbox]

in the After Update under properties of my checkbox control, of course
substituting the TestBox name I wanted to enable for TestBox and the same
for
the Checkbox. When I go back to the form view and click the check box I
get
an error saying the the Macro doesn't exist. Am I supposed to build a
macro
or am I entering something wrong.
--
julostarr


John W. Vinson said:
If I wanted to enable a textbox based on whether a checkbox were
checked,
I'd probably add something like the following in the checkbox's
AfterUpdate
event:

Me!TextBox.Enabled = Me!Checkbox

.... and also the Form's Current event, to handle existing records, I'd
suggest.
 
J

Jeff Boyce

I don't know why the expressioin didn't work ... did you get an error
message? Did you insert a breakpoint in the code so you could step through
it one statement at a time and see what values were being returned?

Congratulations on a solution!

Regards

Jeff Boyce
Microsoft Office/Access MVP


julostarr said:
Well, I never could get the Me![TextBox].Enabled = Me![Checkbox] to work,
but
I played around with an IF Expression and it worked for me. If the
checkbox
is checked it goes to the following field to allow editing and if it is
unchecked then the next field is uneditable and tabbing through it skips
that
field. The code I used goes as follows:

Private Sub Ctl401_k_Participant_AfterUpdate()
If Me![401(k)Participant] = True Then
Me![401(k)%].Enabled = True
Else
Me![401(k)%].Enabled = False
End If
End Sub

I'm still learning about VBA, but this IF conditional express worked for
me
in this situation. I was expecting the field in question to be grayed out
when it was uneditable, but it is fine this way.

If you have any tips for me or can help me understand this a little more
that would be great. If not thank you so much for you help.


--
julostarr


Jeff Boyce said:
If you entered that directly in the space following the label for
AfterUpdate in the properties, Access will try to find a macro with that
name.

To be more specific, you will need to create an AfterUpdate event
procedure
and enter that expression in the event procedure.

Regards

Jeff Boyce
Microsoft Office/Access MVP

julostarr said:
Can you help me out with understanding this a little more. I entered
this:

Me![TextBox].Enabled = Me![Checkbox]

in the After Update under properties of my checkbox control, of course
substituting the TestBox name I wanted to enable for TestBox and the
same
for
the Checkbox. When I go back to the form view and click the check box
I
get
an error saying the the Macro doesn't exist. Am I supposed to build a
macro
or am I entering something wrong.
--
julostarr


:

On Fri, 26 Sep 2008 11:05:41 -0700, "Jeff Boyce"
<[email protected]>
wrote:

If I wanted to enable a textbox based on whether a checkbox were
checked,
I'd probably add something like the following in the checkbox's
AfterUpdate
event:

Me!TextBox.Enabled = Me!Checkbox

.... and also the Form's Current event, to handle existing records,
I'd
suggest.
 
J

julostarr

I did get an error message with the other code before. I'm not sure if it
was because I did't put it in right or what. Anyway, I tried it again and it
worked now. I do have another question though. I notice that with either of
these solutions. The field that I wanted disabled/enabled with relation to
the checkbox is only disabled after I check the box and then uncheck it
again. Is there a way to make it disabled until the checkbox is checked Yes
and then disabled again if the checkbox is unchecked? I realize that the
After Update makes these expressions apply only After Update of course, but I
tried to put these solutions in the Before Update and it didn't change
anything.

I'm also thinking about trying to do something similar with a list/dropdown
box. I would like to make one choice from the list box enable one field and
disable another and do the oposite with another choice from the same
list/dropdown box and maybe a third choice to disable both fields. It seems
like maybe If...Then...Else could be used in some way I'm just unsure exactly
how.

P.S. If my question is confusing let me know and I'll try to rephrase it.
--
julostarr


Jeff Boyce said:
I don't know why the expressioin didn't work ... did you get an error
message? Did you insert a breakpoint in the code so you could step through
it one statement at a time and see what values were being returned?

Congratulations on a solution!

Regards

Jeff Boyce
Microsoft Office/Access MVP


julostarr said:
Well, I never could get the Me![TextBox].Enabled = Me![Checkbox] to work,
but
I played around with an IF Expression and it worked for me. If the
checkbox
is checked it goes to the following field to allow editing and if it is
unchecked then the next field is uneditable and tabbing through it skips
that
field. The code I used goes as follows:

Private Sub Ctl401_k_Participant_AfterUpdate()
If Me![401(k)Participant] = True Then
Me![401(k)%].Enabled = True
Else
Me![401(k)%].Enabled = False
End If
End Sub

I'm still learning about VBA, but this IF conditional express worked for
me
in this situation. I was expecting the field in question to be grayed out
when it was uneditable, but it is fine this way.

If you have any tips for me or can help me understand this a little more
that would be great. If not thank you so much for you help.


--
julostarr


Jeff Boyce said:
If you entered that directly in the space following the label for
AfterUpdate in the properties, Access will try to find a macro with that
name.

To be more specific, you will need to create an AfterUpdate event
procedure
and enter that expression in the event procedure.

Regards

Jeff Boyce
Microsoft Office/Access MVP

Can you help me out with understanding this a little more. I entered
this:

Me![TextBox].Enabled = Me![Checkbox]

in the After Update under properties of my checkbox control, of course
substituting the TestBox name I wanted to enable for TestBox and the
same
for
the Checkbox. When I go back to the form view and click the check box
I
get
an error saying the the Macro doesn't exist. Am I supposed to build a
macro
or am I entering something wrong.
--
julostarr


:

On Fri, 26 Sep 2008 11:05:41 -0700, "Jeff Boyce"
<[email protected]>
wrote:

If I wanted to enable a textbox based on whether a checkbox were
checked,
I'd probably add something like the following in the checkbox's
AfterUpdate
event:

Me!TextBox.Enabled = Me!Checkbox

.... and also the Form's Current event, to handle existing records,
I'd
suggest.
 
J

Jeff Boyce

Given that this new question is somewhat different, you'd get more eyes (and
brains) working on it if you posted it as a new question, rather than
burying it so far down in the current thread.

Regards

Jeff Boyce
Microsoft Office/Access MVP

julostarr said:
I did get an error message with the other code before. I'm not sure if it
was because I did't put it in right or what. Anyway, I tried it again and
it
worked now. I do have another question though. I notice that with either
of
these solutions. The field that I wanted disabled/enabled with relation
to
the checkbox is only disabled after I check the box and then uncheck it
again. Is there a way to make it disabled until the checkbox is checked
Yes
and then disabled again if the checkbox is unchecked? I realize that the
After Update makes these expressions apply only After Update of course,
but I
tried to put these solutions in the Before Update and it didn't change
anything.

I'm also thinking about trying to do something similar with a
list/dropdown
box. I would like to make one choice from the list box enable one field
and
disable another and do the oposite with another choice from the same
list/dropdown box and maybe a third choice to disable both fields. It
seems
like maybe If...Then...Else could be used in some way I'm just unsure
exactly
how.

P.S. If my question is confusing let me know and I'll try to rephrase it.
--
julostarr


Jeff Boyce said:
I don't know why the expressioin didn't work ... did you get an error
message? Did you insert a breakpoint in the code so you could step
through
it one statement at a time and see what values were being returned?

Congratulations on a solution!

Regards

Jeff Boyce
Microsoft Office/Access MVP


julostarr said:
Well, I never could get the Me![TextBox].Enabled = Me![Checkbox] to
work,
but
I played around with an IF Expression and it worked for me. If the
checkbox
is checked it goes to the following field to allow editing and if it is
unchecked then the next field is uneditable and tabbing through it
skips
that
field. The code I used goes as follows:

Private Sub Ctl401_k_Participant_AfterUpdate()
If Me![401(k)Participant] = True Then
Me![401(k)%].Enabled = True
Else
Me![401(k)%].Enabled = False
End If
End Sub

I'm still learning about VBA, but this IF conditional express worked
for
me
in this situation. I was expecting the field in question to be grayed
out
when it was uneditable, but it is fine this way.

If you have any tips for me or can help me understand this a little
more
that would be great. If not thank you so much for you help.


--
julostarr


:

If you entered that directly in the space following the label for
AfterUpdate in the properties, Access will try to find a macro with
that
name.

To be more specific, you will need to create an AfterUpdate event
procedure
and enter that expression in the event procedure.

Regards

Jeff Boyce
Microsoft Office/Access MVP

Can you help me out with understanding this a little more. I
entered
this:

Me![TextBox].Enabled = Me![Checkbox]

in the After Update under properties of my checkbox control, of
course
substituting the TestBox name I wanted to enable for TestBox and the
same
for
the Checkbox. When I go back to the form view and click the check
box
I
get
an error saying the the Macro doesn't exist. Am I supposed to build
a
macro
or am I entering something wrong.
--
julostarr


:

On Fri, 26 Sep 2008 11:05:41 -0700, "Jeff Boyce"
<[email protected]>
wrote:

If I wanted to enable a textbox based on whether a checkbox were
checked,
I'd probably add something like the following in the checkbox's
AfterUpdate
event:

Me!TextBox.Enabled = Me!Checkbox

.... and also the Form's Current event, to handle existing records,
I'd
suggest.
 

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