Simplifying Math techniques

I have a user form defined two text input fields. When the user clicks OK I want to take those two input fields to calculate a formular.

The formular has some technical details that may need to be broken down into simple steps so that it would be easy to calculate.
The attached file shows the type of formular I am talking about which this thread does not accept.

...something like  formular raised to power "1/2" divided and / or multiply by other segments of the formular.

Q4 = (Text1 * 11) 1/2  / [(Text2 + 11 /  (0.66 * 43232)] * 2

Formula-Samples.doc
LVL 4
billcuteAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jim Dettman (Microsoft MVP/ EE MVE)President / OwnerCommented:
Bill,

  If the formula is constant and the inputs are just that, inputs to the formula, then I would code it in a Function procedure in a general module so it is available to the entire app.

  If you want the user to be able to type the formula itself, then you'll need to use the eval function.

JimD.
0
billcuteAuthor Commented:
You said:
 If the formula is constant and the inputs are just that, inputs to the formula, then I would code it in a Function procedure in a general module so it is available to the entire app.

Response:
This sounds great. Any idea of what the function would look like?

You said:
If you want the user to be able to type the formula itself, then .....

Response:
No user does not need to type the formula....user will type only the text inputs (Text1 and Text2).
0
BadotzCommented:
Something like:

Function X(ByVal Y as String, ByVal Z as String) AS Double

    X =  (CDbl(Y) * 11) 1/2  / [(CDbl(Z) + 11) / (0.66 * 43232)] * 2

End Function

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

billcuteAuthor Commented:
Would you mind to explain how this could be utilized.
0
BadotzCommented:
Put

=X(Text1, Text2)

in the cell you wish to store the calculation.
0
billcuteAuthor Commented:
ok:
This is still not clear. Let's try again.
Here is my initial formula (see the attached downloadable filefor the rest formula)
Q4 = (Text1 * 11) 1/2  / [(Text2 + 11 /  (0.66 * 43232)] * 2

I pasted your suggested Function in the form and placed the =X(Text1, Text2) in the Control Source of Q4 text box per the above formula.

I opened the form and entered 123 and 432 in Text1 and Text2 respectively.

Q4 textbox displayed #Error.

Am I doing something wrong?
0
Jim Dettman (Microsoft MVP/ EE MVE)President / OwnerCommented:
When you call a procedure from anything other then VBA (in code), then you need to use a full reference:

=x(Forms![<myFormName>]![<myControlName1>], Forms![<myFormName>]![<myControlName2>])

replacing everything in the <> and including them with the actual names of the form and controls.

If you were doing this in code, say from the after update event of myControlName1 or myControlName2,, then it woul look like this:

Me.<myControlNameResult> = x(Me.<myControlName1>, Me.<myControlName2>)

When your executing in code in a form, Me. replaces Forms![<myFormName>]

JimD.
0
billcuteAuthor Commented:
Jim:
I tried this: -
=X([Me]![frmTest]![Text1],[Me]![frmTest]![Test2])

...I received an error..... #Name?
0
Jim Dettman (Microsoft MVP/ EE MVE)President / OwnerCommented:
<<=X([Me]![frmTest]![Text1],[Me]![frmTest]![Test2])>>

  If this is in code:

=X(Me.Text1,Me.Test2)

  and shouldn't that be "Text2" not "Test2".

  If your using that for a control source:

=x(Forms![frmTest]![Text1],Forms![frmTest]![Test2])

JimD.
0
billcuteAuthor Commented:
Ok:
Maybe I am doing something wrong. Would you mind uploading a sample db based on the info I provided above.
0
billcuteAuthor Commented:
Jim:
Thanks for the explanation. I assume what I needed to use is the Me!......and not Forms!
since I am currently loading FrmTest as my main form.

Anyway, I tried the line below and I recived #Error?
=x([Forms]![frmTest]![Text1],[Forms]![frmTest]![Text2])

Are we sure the pasted Function behind frmTest is being referenced correctly?

Function X(ByVal Y As String, ByVal Z As String) As Double
    X = (CDbl(Y) * 11) / 2 / [(CDbl(Z) + 11) / (0.66 * 43232)] * 2
End Function
0
Jim Dettman (Microsoft MVP/ EE MVE)President / OwnerCommented:
Bill,

  Your formula is typed incorrectly (you can't use [] brackets).

  Sample is attached.

  Result will show a #Error until text1 and text2 have a number in them.

JimD.
db1.mdb
0
billcuteAuthor Commented:
Thanks Jim:
I will request a tweak to the fucntion using a related question option
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.