Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Simplifying Math techniques

Posted on 2008-11-16
13
Medium Priority
?
270 Views
Last Modified: 2013-11-27
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
0
Comment
Question by:billcute
  • 7
  • 4
  • 2
13 Comments
 
LVL 59

Assisted Solution

by:Jim Dettman (Microsoft MVP/ EE MVE)
Jim Dettman (Microsoft MVP/ EE MVE) earned 500 total points
ID: 22970843
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
 
LVL 4

Author Comment

by:billcute
ID: 22970879
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
 
LVL 29

Accepted Solution

by:
Badotz earned 500 total points
ID: 22970988
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 4

Author Comment

by:billcute
ID: 22971070
Would you mind to explain how this could be utilized.
0
 
LVL 29

Assisted Solution

by:Badotz
Badotz earned 500 total points
ID: 22971133
Put

=X(Text1, Text2)

in the cell you wish to store the calculation.
0
 
LVL 4

Author Comment

by:billcute
ID: 22971221
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
 
LVL 59
ID: 22971310
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
 
LVL 4

Author Comment

by:billcute
ID: 22971468
Jim:
I tried this: -
=X([Me]![frmTest]![Text1],[Me]![frmTest]![Test2])

...I received an error..... #Name?
0
 
LVL 59

Assisted Solution

by:Jim Dettman (Microsoft MVP/ EE MVE)
Jim Dettman (Microsoft MVP/ EE MVE) earned 500 total points
ID: 22971580
<<=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
 
LVL 4

Author Comment

by:billcute
ID: 22971785
Ok:
Maybe I am doing something wrong. Would you mind uploading a sample db based on the info I provided above.
0
 
LVL 4

Author Comment

by:billcute
ID: 22971786
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
 
LVL 59
ID: 22971879
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
 
LVL 4

Author Comment

by:billcute
ID: 22971998
Thanks Jim:
I will request a tweak to the fucntion using a related question option
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

569 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question