What event when I click the record selector

A

Alan T

I have some labels on the form would like to populate its value (they are
calculated values) when I select the record selector, next, previous or last
or first.

What event should I write the code into?
 
J

John W. Vinson

I have some labels on the form would like to populate its value (they are
calculated values) when I select the record selector, next, previous or last
or first.

What event should I write the code into?

Well, don't use Labels for this purpose; use textboxes instead, with their
Control Source set to the expression. Doing so will display the calculated
value with no code at all.

John W. Vinson [MVP]
 
A

Alan T

Hi,
My calculated fields do not exists in the table, I need to calculate on the
fly.
So I cannot link the text box/label to the recordset.
 
R

Rick Brandt

Alan said:
Hi,
My calculated fields do not exists in the table, I need to calculate
on the fly.
So I cannot link the text box/label to the recordset.

That is not what John suggested. A TextBox can have an expression as its
ControlSource and thus display a value that has nothing to do with the form's
RecordSource.
 
J

John W. Vinson

My calculated fields do not exists in the table, I need to calculate on the
fly.

Then do so.

You can set the Control Source of a textbox to

=(([FieldA] + [FieldB]) / IIF([FieldC] > [FieldD], [FieldC], [FieldD])

or any other expression that you choose.

John W. Vinson [MVP]
 
A

Alan T

I understand it but my calculated fields depends on fields of other tables.
I need to run a query may have a SUM(..) in the SELECT part.


John W. Vinson said:
My calculated fields do not exists in the table, I need to calculate on
the
fly.

Then do so.

You can set the Control Source of a textbox to

=(([FieldA] + [FieldB]) / IIF([FieldC] > [FieldD], [FieldC], [FieldD])

or any other expression that you choose.

John W. Vinson [MVP]
 
J

John W. Vinson

I understand it but my calculated fields depends on fields of other tables.
I need to run a query may have a SUM(..) in the SELECT part.

You can use the builtin DSum() function, or create a stored query and use
DLookUp to retrieve a value from that query. You don't say anything about the
nature of the calculation so I really can't be much help other than that!

John W. Vinson [MVP]
 
Top