Expression Precedence

fuzzygeek

Energy Ebbing
Local time
Today, 16:32
Joined
Mar 28, 2003
Messages
989
Someone that I work with teaches ACCESS. She was demonstrating using expressions in a query for her class when one of the students asked why. The field in the table is defined as currency called Wage. The first expression is Wage * 0.10 named Increase. The second expression is Wage + Increase named NewSalary.

Attached is the query results. The question was why does the Wage show as controlled decimal, the increase shows as an uncontrolled decimal. And the NewSalary show as currency.

I believe this has to do with precedence, but was unable to find it in the knowledge base or the help screen. I tried expressions and/or precedence here in the archieves, but perhaps I wasn't using the right words. Does anyone have a link or a good explanation that she can give her class.

Thanks in advance.
 

Attachments

Last edited:
The key here is property inheritance in a query based on a table.

Wage must have been defined in the table as having the controlled decimal amount.

Increase is an expression which is probably not declared. As such, it is a Variant that has no format. (Look up Variant in the Help Files if you don't know what that is.)

Salary must have been defined based on something having a controlled decimal amount. It is a field to which a variant has been added. But variants are chameleons. Add a numeric variant to an integer, you could jolly well get an integer. Add it to a DOUBLE, you get a DOUBLE. Add it to a currency, you obviously get a currency. So I think the principle you are looking for is 'inheritance' - not precedence.

Precedence tells you what happens in a statement like

A = B + C * D

Precedence rules (for VBA) would tell you that the statement is

A = B + ( C * D )

and not

A = ( B + C ) * D

The latter would be either the "add first" or the "no precedence" case.
 
It is obvious that I totally misworded the question so I'll rewrite what the question should have been. The class is a first class in MS ACCESS. The students are in the first two weeks. The instructor knows absolutely no VBA, thus she doesn't know how to ask the vba help in the module area. What I was asking for was a very simple explanation that complete newbies could grasp...which is what I was originally unable to communicate to the instructor. Yes I used precedence when I meant inheritance. The effects of too many years of hooch, and not enough Ripple or Thunderbird for vitamins. I used your words and with what I had gotten from other books, gave her an explanation that she understood and will communicate to the students. :cool:
 

Users who are viewing this thread

Back
Top Bottom