View Full Version : table entry from forms


Terryb
07-14-2000, 05:57 AM
I want to make a calculation in a form and have it entered in a table field.

DML
07-14-2000, 07:12 AM
Add a text box that is bound to the field that you want to store the calculated value in. If the calculations are based on the user's entry in some other fields, you can use the After Update event of those entry fields to perform your calculation and assign the result to the bound text box. The syntax would look something like this...

me.[TextboxToStoreValue] = me.[TextValue1] + me.[TextValue2]

Hint: You would want to make sure that all the fields you are using in your calculation have a value before you perform the calculation or you might get an error.

musicmaker
07-15-2000, 08:02 AM
Dear Terryb and DML

I need to be able to do this also, however, I could not get it to work as outlined above.
My expression builder modifies the above to a point where I get error messeges only! Can anybody tell me the correct way to solve this? Thank you in advance.

My email address is: musicmaker@aristotle.net

DML
07-17-2000, 06:40 AM
Musicmaker,

What error messages are you getting? You may have some properties set differently than I have assumed for the above example.

Eve
08-01-2000, 09:19 AM
I need to do the same thing. How do you create a bound textbox. The only textbox that I know how to create says unbound.

I'm new at this!

Richie
08-01-2000, 09:37 AM
Why do you need to "store" a calculated field?

Eve
08-01-2000, 09:44 AM
I need to store number of days based on the difference of start and end dates.

musicmaker
08-02-2000, 10:39 AM
For storing calculations when using forms, I have found that if you write your formula in VB code instead of using the expression builder, that it stores the calculations in YOUR Tables! Example:

NAME
OF
FIELDS (in your table)

1stAmt
2ndAmt
3rdAmt
TotAmt

Next, make a form.

Then, Go to design mode and right click properties. Go to event.
Go down to On Enter.

Click and go into the code builder (not the expression builder). As soon as it opens up, you will see that the builder has automatically put two lines in there for you. That is your first line and last line of code. You insert your formula into the center. The formula for the above is:

TotAmt = ([1stAmt] + [2ndAmt] + [3rdAmt])

Your code layout will look like this:


Private Sub (name of field)_Enter

TotAmt = ([1stAmt] + [2ndAmt] + [3rdAmt])

End Sub

Hope this solves your calculation problems, It solved mine.