By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,456 Members | 1,529 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,456 IT Pros & Developers. It's quick & easy.

This is different: Converting a formula to a value

P: n/a
Don't ask why, this is just something a client wants to do...

I want to put a form in my database with 4 text boxes; txtA, txtB,
txtFormula and txtValue

The client wants to be able to enter numbers into txtA and txtB. He
then wants to be able to enter a formula in txtFormula and spit the
value into txtValue.

So, for instance, he enters 6 into txtA and 10 into txtB. In
txtFormula he types; (txtA + txtB) / 2

txtValue should then display the number 8.

Is this possible?

Jun 4 '07 #1
Share this Question
Share on Google+
10 Replies


P: n/a
ManningFan wrote:
Don't ask why, this is just something a client wants to do...

I want to put a form in my database with 4 text boxes; txtA, txtB,
txtFormula and txtValue

The client wants to be able to enter numbers into txtA and txtB. He
then wants to be able to enter a formula in txtFormula and spit the
value into txtValue.

So, for instance, he enters 6 into txtA and 10 into txtB. In
txtFormula he types; (txtA + txtB) / 2

txtValue should then display the number 8.

Is this possible?
txtA = 1
txtb = 2
? Eval((txtA + txtB) / 2)
1.5

Jun 4 '07 #2

P: n/a
On Jun 4, 12:07 pm, salad <o...@vinegar.comwrote:
ManningFan wrote:
Don't ask why, this is just something a client wants to do...
I want to put a form in my database with 4 text boxes; txtA, txtB,
txtFormula and txtValue
The client wants to be able to enter numbers into txtA and txtB. He
then wants to be able to enter a formula in txtFormula and spit the
value into txtValue.
So, for instance, he enters 6 into txtA and 10 into txtB. In
txtFormula he types; (txtA + txtB) / 2
txtValue should then display the number 8.
Is this possible?

txtA = 1
txtb = 2
? Eval((txtA + txtB) / 2)
1.5- Hide quoted text -

- Show quoted text -
For some reason that works when you do it like that, but not when you
do Eval(Me.txtFormula). I know I'm close, just not quite there yet.

Jun 4 '07 #3

P: n/a

"ManningFan" <ma********@gmail.comwrote in message
news:11*********************@o5g2000hsb.googlegrou ps.com...
On Jun 4, 12:07 pm, salad <o...@vinegar.comwrote:
ManningFan wrote:
Don't ask why, this is just something a client wants to do...
I want to put a form in my database with 4 text boxes; txtA, txtB,
txtFormula and txtValue
The client wants to be able to enter numbers into txtA and txtB. He
then wants to be able to enter a formula in txtFormula and spit the
value into txtValue.
So, for instance, he enters 6 into txtA and 10 into txtB. In
txtFormula he types; (txtA + txtB) / 2
txtValue should then display the number 8.
Is this possible?
txtA = 1
txtb = 2
? Eval((txtA + txtB) / 2)
1.5- Hide quoted text -

- Show quoted text -

For some reason that works when you do it like that, but not when you
do Eval(Me.txtFormula). I know I'm close, just not quite there yet.
I think you will need to better define txtA and txtB.

? Evail(([txtA] + [txtB]) / 2)

You will more likely need to define a function to parse the formula and
return a value.
Jun 4 '07 #4

P: n/a
On Jun 4, 2:02 pm, "paii, Ron" <p...@packairinc.comwrote:
"ManningFan" <manning...@gmail.comwrote in message

news:11*********************@o5g2000hsb.googlegrou ps.com...
On Jun 4, 12:07 pm, salad <o...@vinegar.comwrote:
ManningFan wrote:
Don't ask why, this is just something a client wants to do...
I want to put a form in my database with 4 text boxes; txtA, txtB,
txtFormula and txtValue
The client wants to be able to enter numbers into txtA and txtB. He
then wants to be able to enter a formula in txtFormula and spit the
value into txtValue.
So, for instance, he enters 6 into txtA and 10 into txtB. In
txtFormula he types; (txtA + txtB) / 2
txtValue should then display the number 8.
Is this possible?
txtA = 1
txtb = 2
? Eval((txtA + txtB) / 2)
1.5- Hide quoted text -
- Show quoted text -
For some reason that works when you do it like that, but not when you
do Eval(Me.txtFormula). I know I'm close, just not quite there yet.

I think you will need to better define txtA and txtB.

? Evail(([txtA] + [txtB]) / 2)

You will more likely need to define a function to parse the formula and
return a value.- Hide quoted text -

- Show quoted text -
I got it. I had to use a Replace function to make it insert Forms!
frmExample.txtA wherever it found txtA, and likewise for txtB. For
whatever reason it understands the fields in the Immediate window but
doesn't understand them if you leave it in code.

Access is quirky sometimes...

Jun 4 '07 #5

P: n/a
On Mon, 04 Jun 2007 08:41:14 -0700, ManningFan <ma********@gmail.comwrote:
>Don't ask why, this is just something a client wants to do...

I want to put a form in my database with 4 text boxes; txtA, txtB,
txtFormula and txtValue

The client wants to be able to enter numbers into txtA and txtB. He
then wants to be able to enter a formula in txtFormula and spit the
value into txtValue.

So, for instance, he enters 6 into txtA and 10 into txtB. In
txtFormula he types; (txtA + txtB) / 2

txtValue should then display the number 8.

Is this possible?
Don't suppose the client would be happy with just a command button to open the
Windows Calculator.

Chuck
--

Jun 4 '07 #6

P: n/a
On Jun 4, 4:16 pm, Chuck <libb...@schoollink.netwrote:
On Mon, 04 Jun 2007 08:41:14 -0700, ManningFan <manning...@gmail.comwrote:
Don't ask why, this is just something a client wants to do...
I want to put a form in my database with 4 text boxes; txtA, txtB,
txtFormula and txtValue
The client wants to be able to enter numbers into txtA and txtB. He
then wants to be able to enter a formula in txtFormula and spit the
value into txtValue.
So, for instance, he enters 6 into txtA and 10 into txtB. In
txtFormula he types; (txtA + txtB) / 2
txtValue should then display the number 8.
Is this possible?

Don't suppose the client would be happy with just a command button to open the
Windows Calculator.

Chuck
--- Hide quoted text -

- Show quoted text -
It's a bit deeper than that, actually. Although even if it wasn't,
clients are never satisfied with solutions like that.

Jun 4 '07 #7

P: n/a
I haven't tried it but you could try the Eval function. Mmmm...I must make a
note to try that.

Else you probably have to parse it and then human error will be a problem.

Tricky.

Jeff
"More Access Stuff."
http://www.asken.com.au

"ManningFan" <ma********@gmail.comwrote in message
news:11**********************@k79g2000hse.googlegr oups.com...
Don't ask why, this is just something a client wants to do...

I want to put a form in my database with 4 text boxes; txtA, txtB,
txtFormula and txtValue

The client wants to be able to enter numbers into txtA and txtB. He
then wants to be able to enter a formula in txtFormula and spit the
value into txtValue.

So, for instance, he enters 6 into txtA and 10 into txtB. In
txtFormula he types; (txtA + txtB) / 2

txtValue should then display the number 8.

Is this possible?

Jun 5 '07 #8

P: n/a
Try Eval(Me!txtFormula).

The '.' should be '!'.

Jeff
"More Access Stuff."
http://www.asken.com.au

"ManningFan" <ma********@gmail.comwrote in message
news:11*********************@o5g2000hsb.googlegrou ps.com...
On Jun 4, 12:07 pm, salad <o...@vinegar.comwrote:
>ManningFan wrote:
Don't ask why, this is just something a client wants to do...
I want to put a form in my database with 4 text boxes; txtA, txtB,
txtFormula and txtValue
The client wants to be able to enter numbers into txtA and txtB. He
then wants to be able to enter a formula in txtFormula and spit the
value into txtValue.
So, for instance, he enters 6 into txtA and 10 into txtB. In
txtFormula he types; (txtA + txtB) / 2
txtValue should then display the number 8.
Is this possible?

txtA = 1
txtb = 2
? Eval((txtA + txtB) / 2)
1.5- Hide quoted text -

- Show quoted text -

For some reason that works when you do it like that, but not when you
do Eval(Me.txtFormula). I know I'm close, just not quite there yet.

Jun 5 '07 #9

P: n/a
On Jun 5, 7:40 am, "Jeff" <jeff.pritch...@asken.com.auwrote:
Try Eval(Me!txtFormula).

The '.' should be '!'.

Jeff
"More Access Stuff."http://www.asken.com.au

"ManningFan" <manning...@gmail.comwrote in message

news:11*********************@o5g2000hsb.googlegrou ps.com...
On Jun 4, 12:07 pm, salad <o...@vinegar.comwrote:
ManningFan wrote:
Don't ask why, this is just something a client wants to do...
I want to put a form in my database with 4 text boxes; txtA, txtB,
txtFormula and txtValue
The client wants to be able to enter numbers into txtA and txtB. He
then wants to be able to enter a formula in txtFormula and spit the
value into txtValue.
So, for instance, he enters 6 into txtA and 10 into txtB. In
txtFormula he types; (txtA + txtB) / 2
txtValue should then display the number 8.
Is this possible?
txtA = 1
txtb = 2
? Eval((txtA + txtB) / 2)
1.5- Hide quoted text -
- Show quoted text -
For some reason that works when you do it like that, but not when you
do Eval(Me.txtFormula). I know I'm close, just not quite there yet.- Hide quoted text -

- Show quoted text -
Jeff -
I tried that already. I had to actually specify the form name in
order to get it to work.

Jun 5 '07 #10

P: n/a
Mmm, interesting. At least it works for you.

Jeff
"More Access Stuff."
http://www.asken.com.au

"ManningFan" <ma********@gmail.comwrote in message
news:11*********************@q66g2000hsg.googlegro ups.com...
On Jun 5, 7:40 am, "Jeff" <jeff.pritch...@asken.com.auwrote:
>Try Eval(Me!txtFormula).

The '.' should be '!'.

Jeff
"More Access Stuff."http://www.asken.com.au

"ManningFan" <manning...@gmail.comwrote in message

news:11*********************@o5g2000hsb.googlegro ups.com...
On Jun 4, 12:07 pm, salad <o...@vinegar.comwrote:
ManningFan wrote:
Don't ask why, this is just something a client wants to do...
I want to put a form in my database with 4 text boxes; txtA, txtB,
txtFormula and txtValue
The client wants to be able to enter numbers into txtA and txtB. He
then wants to be able to enter a formula in txtFormula and spit the
value into txtValue.
So, for instance, he enters 6 into txtA and 10 into txtB. In
txtFormula he types; (txtA + txtB) / 2
txtValue should then display the number 8.
Is this possible?
>txtA = 1
txtb = 2
? Eval((txtA + txtB) / 2)
1.5- Hide quoted text -
>- Show quoted text -
For some reason that works when you do it like that, but not when you
do Eval(Me.txtFormula). I know I'm close, just not quite there yet.-
Hide quoted text -

- Show quoted text -

Jeff -
I tried that already. I had to actually specify the form name in
order to get it to work.

Jun 7 '07 #11

This discussion thread is closed

Replies have been disabled for this discussion.