Help with unbound text boxes please.

  • Thread starter alan morgan via
  • Start date

alan morgan via

Is it possible to sum unbound text boxes on a report or use unbound text
boxes in functions?

I have an expression [Expr1] in my report that is based off of a query and it
adds two fields. then i have an unbound text box [txt1] that only displays
the value of [Expr1] if it is possitive using an IIf statement.

This happens twice. [Expr1] & [txt1] calculate AM hours
and [Expr2] & [txt2] calculate PM hours.

How can I sum [txt1] and [txt2] ?

Larry Linson

Unbound text boxes on a report? What you describe is called a "Calculated
Control" -- it has an expression as its Control Source. An unbound text box
would have nothing in its Control Source and would have to be set from VBA
event code.

You can, in the Format or Print events, copy the value from the Calculated
Control to a VBA public variable (or add the value from the CC). What you
have to be careful about is that the Format or Print events may fire
multiple times for the same record, particularly in Preview, when someone is
paging forward and backward. So, your code must check that it has not
already processed the particular record... that can be done... but is easier
said than done in many cases.

If you calculate [Expr1] in the query, instead of on the Report, you will
have no problem. That's the first approach to summation of multiple
fields... if you do the calculation in a Calculated Field in the Query, and
just display it like any other Field, then you can Sum it like any other

Larry Linson
Microsoft Access MVP

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