Expressions in Forms

hsevigny

New member
Local time
Today, 08:19
Joined
Dec 29, 2008
Messages
6
Hi!

I am trying to build an expression that will subtract one item on a form from another item:

Total days out of work - total hours worked per shift.

I have entered an expression in the field that I want the data to go to, but it does not calculate. Can anyone help with how I should build the expression and how to make it so it will calculate data that was previously entered?

Thank you
Heather
 
If you write an expression in the ControlSource property of a TextBox you must prefix it with an equals sign.
Code:
=[your expression goes here]
- or -
Code:
=[txtTotalDaysAbsent]-[txtTotalHoursPerShift]
 
Thank you! This is very helpful. Do you happen to know where the best place is to write the expression. I have tried it through expression builder and on the properties tab but there are 5 different lines you can write it on, I'm not sure which one is right.

Heather
 
Click the Data tab and the first line will be what lagbolt said, that is, ControlSource.

You can type directly on the line or bring up the expression builder but either way you start with = sign.

You can also do it by creating a field in a query, assuming a query is the recordsource of your form. You then display the new field in your form in the sae manner as any other field.

In a query type in the name you want to give the field as follows

YourNewFieldName:[fieldnamedays]-[fieldnamehours]

Note that in a query the formula does not start with an = sign
 
I am having a problem using the expressions here as well and have already done exactly as instructed. All I am trying to do is come up with total shipping cost by using the following expression: =[FreighCharged]-[ActualShipping]

I created the expression in the form called TotalShipping. Whenever I go through the record and enter in those two peices of information it doesn't do anything. I set it to be on click, but not matter what I do nothing works. Any help would be appreciated. Has anyone possibly made a program to calculate eBay fees in Access?
 
You don't set it on click, it occurs as the record is saved.

Lets say you have a field called Price and you enter

10

You have another field Items Sold and you enter

100

Your unbound textbox has

=[Price]*[ItemsSold]

After you entered the 100 if you clicked in any other textbox then the unbound text box would for the above example would show 1000

It is virtually a replica of what happens with Excel
 
Thank you all very much. It was successful. The clue about excel was very helpful, the formula is very similar.

Thanks again!
Heather
 
Thank you all very much. It was successful. The clue about excel was very helpful, the formula is very similar.

Thanks again!
Heather

Just remember in Access textboxes and queries IIF is used not IF. In Access VBA IF is used.
 

Users who are viewing this thread

Back
Top Bottom