Formula Help in a calculated text field

  • Thread starter Lori2836 via AccessMonster.com
  • Start date
L

Lori2836 via AccessMonster.com

Good morning. I'm trying to figure out how to write a formula for a
calculated text field called Cost:


If Hrs is blank, allow a manual entry, otherwise if Date Initiated is <
#4/1/2007#, then Hrs*94.45/1000 else Hrs*99.55/1000

and since I'm not too good at this stuff, I wonder if someone could help?

Thanks!
Lori
 
K

Klatuu

Since you want to allow manual entry in the text box, you can't use the
control source property because this is, I think, a bound control. So I
think the best thing to do would be to use the form's Current event to
populate the control based on whether Hrs has a value.

If Not IsNull(Me.Hrs) Then
If Me.Date < #4/1/2007# Then
Me.CalcControl = Hrs*94.45/1000
Else
Me.CalcControl = Hrs*99.55/1000
End If
End IF

Also, change the name of the control to something other than Date. Date is
a reserved word and using it as a name can cause problems.
And, forms don't have fields. They have controls. Only tables and queries
have fields.
 
L

Lori2836 via AccessMonster.com

Thanks Klatuu! I appreciate your help. If it doesn't work for some reason,
I'll let you know. Have a great weekend.

Lori


Since you want to allow manual entry in the text box, you can't use the
control source property because this is, I think, a bound control. So I
think the best thing to do would be to use the form's Current event to
populate the control based on whether Hrs has a value.

If Not IsNull(Me.Hrs) Then
If Me.Date < #4/1/2007# Then
Me.CalcControl = Hrs*94.45/1000
Else
Me.CalcControl = Hrs*99.55/1000
End If
End IF

Also, change the name of the control to something other than Date. Date is
a reserved word and using it as a name can cause problems.
And, forms don't have fields. They have controls. Only tables and queries
have fields.
Good morning. I'm trying to figure out how to write a formula for a
calculated text field called Cost:
[quoted text clipped - 6 lines]
Thanks!
Lori
 
K

Klatuu

Please do,
You, too.
Mine starts in 15 minutes. Be Back Monday
--
Dave Hargis, Microsoft Access MVP


Lori2836 via AccessMonster.com said:
Thanks Klatuu! I appreciate your help. If it doesn't work for some reason,
I'll let you know. Have a great weekend.

Lori


Since you want to allow manual entry in the text box, you can't use the
control source property because this is, I think, a bound control. So I
think the best thing to do would be to use the form's Current event to
populate the control based on whether Hrs has a value.

If Not IsNull(Me.Hrs) Then
If Me.Date < #4/1/2007# Then
Me.CalcControl = Hrs*94.45/1000
Else
Me.CalcControl = Hrs*99.55/1000
End If
End IF

Also, change the name of the control to something other than Date. Date is
a reserved word and using it as a name can cause problems.
And, forms don't have fields. They have controls. Only tables and queries
have fields.
Good morning. I'm trying to figure out how to write a formula for a
calculated text field called Cost:
[quoted text clipped - 6 lines]
Thanks!
Lori
 
L

Lori2836 via AccessMonster.com

Happy Monday Klatuu. I have tried your suggestion, but for some reason it
isn't working. When you say "current event", exactly what are you talking
about? I have tried to add it in several different areas as an event and I
think I may be putting it in the wrong place.

Thank you!
Lori


Please do,
You, too.
Mine starts in 15 minutes. Be Back Monday
Thanks Klatuu! I appreciate your help. If it doesn't work for some reason,
I'll let you know. Have a great weekend.
[quoted text clipped - 23 lines]
 
K

Klatuu

Open your form in design view.
Open the properties dialog and be sure it says Form in the box at the top
Select the Events tab
Click on the small button with the 3 dots just to the right of the On
Current box.
Select Code Builder
Put the code in there.
--
Dave Hargis, Microsoft Access MVP


Lori2836 via AccessMonster.com said:
Happy Monday Klatuu. I have tried your suggestion, but for some reason it
isn't working. When you say "current event", exactly what are you talking
about? I have tried to add it in several different areas as an event and I
think I may be putting it in the wrong place.

Thank you!
Lori


Please do,
You, too.
Mine starts in 15 minutes. Be Back Monday
Thanks Klatuu! I appreciate your help. If it doesn't work for some reason,
I'll let you know. Have a great weekend.
[quoted text clipped - 23 lines]
Thanks!
Lori
 

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