Relationship field and label and report

G

Guest

Forms
Assets
On the asset form is a button - Depreciation
Sub Form
Most of the expressions accompanying the
labels here are drawn from the Assets table

I created a new label - the expression is a
formula also using fields from the table:

=IIf(Year([DateAcquired])=Year(Date()),IIf
(Month([DateAcquired])<5,[PurchasePrice]/
[DepreciableLife],0))

I edited a column in my report, used the same
label name as the column heading and entered
the same formula in the box but
when you run the report it says "error"

I assume that this is the only was to draw that
same calculation into the report. Or can I
somehow instruct it to display the amount
using a reference to the label as opposed to
the original table - this calculation isn't in
the table...??

Thanks!
 
S

Steve Schapel

You appear to be using the word label to refer to a textbox. A label is
something else.

Your calculation expression would be more correct with either of these...
=IIf(Year([DateAcquired])=Year(Date()) And
Month([DateAcquired])<5,[PurchasePrice]/[DepreciableLife],0)
or...
=IIf([DateAcquired] Between DateSerial(Year(Date()),1,1) And
DateSerial(Year(Date()),5,0),[PurchasePrice]/[DepreciableLife],0)

I got lost as to what you are really trying to do, but here are a couple
of comments that might help...
- if you are putting this expression as the Control Source property
setting of a textbox on a form or report, the name of the textbox will
have to be something other than the name of one of the fields in the
recordsource table/query of the form/report.
- if you are putting this expression as the Control Source property
setting of a textbox on a form or report, the fields it references (in
this case DateAcquired, PurchasePrice, and DepreciableLife) must all be
included in the table/query that the form/report is based on.
- An alternative way of doing this is to use this expression in a
calculated field in a query, and then based the form or report on the query.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top