Calculating fields within a SubForm for each record

  • Thread starter Thread starter JNLSeb
  • Start date Start date
J

JNLSeb

When a SubForm is loading currently a calculation is being done for each
record but the values are based only on the first. So, if the subform has 20
records, the value of this "special" field is being populated for all 20
fields but the value is done based only on the first and not each individual
record.

Where should the code be place to have it calculated for each record on the
subform?
 
JNLSeb said:
When a SubForm is loading currently a calculation is being done for each
record but the values are based only on the first. So, if the subform has 20
records, the value of this "special" field is being populated for all 20
fields but the value is done based only on the first and not each individual
record.

Where should the code be place to have it calculated for each record on the
subform?


Either in the report text box's control source expression or
as a calculated field in the (sub)form's record source
query.
 
Thanks for the input, but I should have been more clear but was not sure how
to describe what I am doing.
This may be better.

I am actually calculating the size of an embedded picture based on the value
of a specific field.
This picture is not stored within any table and is displayed at a given size
only when the data is viewed within the form.
 
Somehow, I had gotten the impression you were talking about
a continuous form where setting any property in VBA will
affect all the displayed records.

In single form view you can also use the form's Current
event to adjust each record at the time a user navigates
from one record to another.
 
Your original assumption was correct and does work for any given "data"
field, but if trying to adjust the size of a given control (or image) for
each record display is a huge puzzle.

There can be anywhere from 1-5 records on the screen and I can get it to
work has i navigate through each record, but this still changes the size for
all the other records as well.

Imagine a Department and Employee master Detail form.
The Department is the master and the Detail are all employees for a given
department.
The picture field control size for each employee on the Detail (or Subform)
is calculated via a field within the Employee table.

When this form loads, each employee within the detail section should appear
with their own image sized accordingly. But currently when the form loads
all the employees pictures are the size of the first. As I navigate through
each employee, the size does change, but it changes for all the employees as
opposed to individula employees.

I would like to provide an actual sample, but this is the best I could do.
Thanks again for ready.


Marshall Barton said:
Somehow, I had gotten the impression you were talking about
a continuous form where setting any property in VBA will
affect all the displayed records.

In single form view you can also use the form's Current
event to adjust each record at the time a user navigates
from one record to another.
--
Marsh
MVP [MS Access]

Thanks for the input, but I should have been more clear but was not sure
how
to describe what I am doing.
This may be better.

I am actually calculating the size of an embedded picture based on the
value
of a specific field.
This picture is not stored within any table and is displayed at a given
size
only when the data is viewed within the form.
 
I understand, but, as I said in my first response, you can
not set control properties for individual rows in a
continuous form. There is only one control and any property
you set will apply to all copies of that control.

Is there any way you can avoid this issue by standardizing
the size of the pictures? If not, the usual fall back
position is to remove the picture from the detail section
and only display the current record's picture somewhere
else, e.g. the (sub)form's header or footer section.
 
Back
Top