how to catch values from a texts to use it as values

M

Marco Silva

Hi. I want to create a formula system in my access program.

So I using a little funcionality that I already have in my system that make
calcs using a prompt command.

So, I'm trying to load a text value that as the formula:
(([Field1]*[field2]*[field3]*[field4])/[field5])

but this don't work because the form cannot use the text values, it uses
text, imagine this:

I havee in this fields:
field1: 10
field2: 30
field3: 2
field4: 14
field5: 12

I want that my value is: 700

My problem is that the form cannot understand that it should not use the
text but the inside numbers.

I also tried to make this in a query. I made a field name toalvalor: and
then I put the column name: ValorTotal: [formula]

But without sucess.

How can I solve this?


Regards,
Marco
 
O

Ofer Cohen

Not sure what you mean by "the form cannot understand that it should not use
the
text but the inside numbers"

What Inside numbers?

If the fields are text type, then convert it numbers using Val

=(Val([Field1])*Val([field2])*Val([field3])*Val([field4]))/Val([field5])

And to make sure, you can replacd Null with 0 using Nz function

=(Val(Nz([Field1],0))*Val(Nz([field2],0))*Val(Nz([field3],0))*Val(Nz([field4],0)))/Val([field5])
 
L

Linq Adams via AccessMonster.com

Don't know the exact usage for this formula, but dividing by 1 is the same as
not dividing at all, and some users may leave Field5 empty if they don't want
it divided by anything. If Field5 is left empty this will bomb, so maybe use
Nz and replace a Null with 1 in this case.

/Val(Nz([field5],1)
 
M

Marco Silva

hi. It's almost as you are saying but it's not working.

I need that the form don't see that only as text but as a formula.

Imagine. If I write
=(Val([Field1])*Val([field2])*Val([field3])*Val([field4]))/Val([field5]) in
VBA code the form will reads as a formula, if I load this from a text on a
form it will think that this is text.

What you you think?

Regards,
marco




Ofer Cohen said:
Not sure what you mean by "the form cannot understand that it should not use
the
text but the inside numbers"

What Inside numbers?

If the fields are text type, then convert it numbers using Val

=(Val([Field1])*Val([field2])*Val([field3])*Val([field4]))/Val([field5])

And to make sure, you can replacd Null with 0 using Nz function

=(Val(Nz([Field1],0))*Val(Nz([field2],0))*Val(Nz([field3],0))*Val(Nz([field4],0)))/Val([field5])

--
Good Luck
BS"D


Marco Silva said:
Hi. I want to create a formula system in my access program.

So I using a little funcionality that I already have in my system that make
calcs using a prompt command.

So, I'm trying to load a text value that as the formula:
(([Field1]*[field2]*[field3]*[field4])/[field5])

but this don't work because the form cannot use the text values, it uses
text, imagine this:

I havee in this fields:
field1: 10
field2: 30
field3: 2
field4: 14
field5: 12

I want that my value is: 700

My problem is that the form cannot understand that it should not use the
text but the inside numbers.

I also tried to make this in a query. I made a field name toalvalor: and
then I put the column name: ValorTotal: [formula]

But without sucess.

How can I solve this?


Regards,
Marco
 

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