Make text box control source change based on a check box selection

  • Thread starter Thread starter AimeeK via AccessMonster.com
  • Start date Start date
A

AimeeK via AccessMonster.com

Hello, I am trying to set up a form in a user has to select one of 2 check
boxes: Margin (Check 158) or Markup (Check 160). Then the user will tab
down to a text box in which they are supposed to enter a percentage (Text215).
Here's my problem: If the user selects Check 160, and enters a percentage in
Text215, I need it to perform a formula, and put it in another text box
(Text354). However, if Check 158 is selected, the user will enter the
percentage into Text215 as usual, and then Text354's value will equal the
percentage that is in Text215.

I know I probably have to change the control source of Text354 to a formula
something like this:

=IIf(Check160 Is Not Null, [Text215]/(1+([Text215]/100)),[Text215]...I know I
must be close, but I keep getting a #Name? error.

Can anyone help? Sorry for all the meaningless control names, and thanks in
advance for your help.
 
Check boxes have three states - Null (gray), Yes (checked), and No (white).
When the form is opened they are gray unless you have an event/macro to set
them.
In your case I would suggest using an Option Group as your check boxes could
both be the same.
 
Allow me to clarify: The two check boxes are a part of an option group
(Frame 155), and the value for Margin is 1, and the value for Markup is 2.
Basically, if the value is 2, I need the control source of Text354 to be my
formula...thanks again.

KARL said:
Check boxes have three states - Null (gray), Yes (checked), and No (white).
When the form is opened they are gray unless you have an event/macro to set
them.
In your case I would suggest using an Option Group as your check boxes could
both be the same.
Hello, I am trying to set up a form in a user has to select one of 2 check
boxes: Margin (Check 158) or Markup (Check 160). Then the user will tab
[quoted text clipped - 13 lines]
Can anyone help? Sorry for all the meaningless control names, and thanks in
advance for your help.
 
You could do it in a Case statement...
Select Case Me.Frame155
Case 1
strFormula = <insert formula here>
Case 2
strFormula = me.text215
End Select
me.text354 = strFormula

Keep in mind I'm an Access noob, and this is not tested in any way. It's
just an idea to try.

d

AimeeK via AccessMonster.com said:
Allow me to clarify: The two check boxes are a part of an option group
(Frame 155), and the value for Margin is 1, and the value for Markup is 2.
Basically, if the value is 2, I need the control source of Text354 to be
my
formula...thanks again.

KARL said:
Check boxes have three states - Null (gray), Yes (checked), and No
(white).
When the form is opened they are gray unless you have an event/macro to
set
them.
In your case I would suggest using an Option Group as your check boxes
could
both be the same.
Hello, I am trying to set up a form in a user has to select one of 2
check
boxes: Margin (Check 158) or Markup (Check 160). Then the user will
tab
[quoted text clipped - 13 lines]
Can anyone help? Sorry for all the meaningless control names, and
thanks in
advance for your help.
 
Just reread Karl's post, I agree that you would need to do this as Option
Group instead of a Frame (I think), then the case statements I suggested
should work...

d


Darhl Thomason said:
You could do it in a Case statement...
Select Case Me.Frame155
Case 1
strFormula = <insert formula here>
Case 2
strFormula = me.text215
End Select
me.text354 = strFormula

Keep in mind I'm an Access noob, and this is not tested in any way. It's
just an idea to try.

d

AimeeK via AccessMonster.com said:
Allow me to clarify: The two check boxes are a part of an option group
(Frame 155), and the value for Margin is 1, and the value for Markup is
2.
Basically, if the value is 2, I need the control source of Text354 to be
my
formula...thanks again.

KARL said:
Check boxes have three states - Null (gray), Yes (checked), and No
(white).
When the form is opened they are gray unless you have an event/macro to
set
them.
In your case I would suggest using an Option Group as your check boxes
could
both be the same.

Hello, I am trying to set up a form in a user has to select one of 2
check
boxes: Margin (Check 158) or Markup (Check 160). Then the user will
tab
[quoted text clipped - 13 lines]
Can anyone help? Sorry for all the meaningless control names, and
thanks in
advance for your help.
 
Darhl, I copied and pasted your code into the AfterUpdate event for Frame155
(which I think is the name of the Option Group), but I keep getting an error
saying "You can't assign a value to this object", and when I go to debug the
code, it shows this as the offending code:

Me.Text354 = strFormula

The full code I used is below:

Private Sub Frame155_AfterUpdate()
Select Case Me.Frame155
Case 1
strFormula = [SPL PERISHABLE PERCENT] / (1 + ([SPL PERISHABLE PERCENT] /
[SPL PERISHABLE PERCENT]))
Me.Text354 = strFormula
Case 2
strFormula = Me.Text215
End Select
End Sub

Did I do something wrong? Thanks.

Darhl said:
Just reread Karl's post, I agree that you would need to do this as Option
Group instead of a Frame (I think), then the case statements I suggested
should work...

d
You could do it in a Case statement...
Select Case Me.Frame155
[quoted text clipped - 34 lines]
 
Okay, I figured this out: I ended up using an IF/THEN STATEMENT and putting
that in the AfterUpdate event of of Text215. I also wrote code for both
check boxes in their MouseDown events so the formula could change according
to which box was checked.

Darhl, Thank you very much...you at least steered me in the right direction.
Darhl, I copied and pasted your code into the AfterUpdate event for Frame155
(which I think is the name of the Option Group), but I keep getting an error
saying "You can't assign a value to this object", and when I go to debug the
code, it shows this as the offending code:

Me.Text354 = strFormula

The full code I used is below:

Private Sub Frame155_AfterUpdate()
Select Case Me.Frame155
Case 1
strFormula = [SPL PERISHABLE PERCENT] / (1 + ([SPL PERISHABLE PERCENT] /
[SPL PERISHABLE PERCENT]))
Me.Text354 = strFormula
Case 2
strFormula = Me.Text215
End Select
End Sub

Did I do something wrong? Thanks.
Just reread Karl's post, I agree that you would need to do this as Option
Group instead of a Frame (I think), then the case statements I suggested
[quoted text clipped - 7 lines]
 
Aimee,

You're very welcome. I know my idea wasn't exactly what you used, but at
least it helped. I think this is the first time I've helped someone in
these forums, so I feel a little better about always asking for help myself
;-)

Darhl


AimeeK via AccessMonster.com said:
Okay, I figured this out: I ended up using an IF/THEN STATEMENT and
putting
that in the AfterUpdate event of of Text215. I also wrote code for both
check boxes in their MouseDown events so the formula could change
according
to which box was checked.

Darhl, Thank you very much...you at least steered me in the right
direction.
Darhl, I copied and pasted your code into the AfterUpdate event for
Frame155
(which I think is the name of the Option Group), but I keep getting an
error
saying "You can't assign a value to this object", and when I go to debug
the
code, it shows this as the offending code:

Me.Text354 = strFormula

The full code I used is below:

Private Sub Frame155_AfterUpdate()
Select Case Me.Frame155
Case 1
strFormula = [SPL PERISHABLE PERCENT] / (1 + ([SPL PERISHABLE PERCENT]
/
[SPL PERISHABLE PERCENT]))
Me.Text354 = strFormula
Case 2
strFormula = Me.Text215
End Select
End Sub

Did I do something wrong? Thanks.
Just reread Karl's post, I agree that you would need to do this as Option
Group instead of a Frame (I think), then the case statements I suggested
[quoted text clipped - 7 lines]
thanks in
advance for your help.
 
Back
Top