CCP
CCP

Reputation: 129

Calculated Textbox based on values from two fields in a form

I am having trouble trying to create an expression that will give me a total based on two values in two different text boxes.

I created a form that has a text box called Niin, textbox called variance, textbox called price and textbox called Total. I also have a table called NIIN_PRICE that has a NIIN column and a price column next to the associated Niin.

The result i am seeking is: Have the value entered in textbox Niin lookup the corresponding value in Table NIIN_PRICE WHICH will then output the price into the Price textbox.

I will then want the total textbox to be an expression by multiplying the value in variance textbox with the value in price textbox and get the total of both numbers.

Example:

I type 1234 in NIIN textbox in my form, 1234 is searched in the NIIN_PRICE table and returns the value of .25. .25 is added to the price textbox as an output. i then type 4 in the variance textbox which will update my value in the total textbox to 1 (.25 from the price pull Multiplied by 4 from my variance input).

Is this request possible? Thank you for the help.

Upvotes: 0

Views: 214

Answers (1)

donPablo
donPablo

Reputation: 1969

theForm might look like this>>
tbxNIIN  tbxPrice  tbxVariance  tbxTotal

on tbxNIIN event tab add AfterUpdate sub
that reads the NIIN_PRICE table and copies the value to tbxPrice
and then clears tbxVariance and tbxTotal
and sets cursor to tbxVariance.

On tbxVariance event tab add AfterUpdate sub
that multiplies the two and puts the result in tbxTotal

Upvotes: 1

Related Questions