Using code window in reports

  • Thread starter Thread starter Tim
  • Start date Start date
T

Tim

Hello,

I placed this on the forms NG, but then I decided that it
is better placed here. So, here it is.

I hope I can explain this. I have a form that a user
completes and then clicks on a command button to produce a
report which pulls data from an employee table. One field
on the report is created from about 8 fields in the
employee table and is based on how the form was filled
out. Trying to place all the code that is need for this
field in the expression builder is very hard to do. What
I have done is created 8 non-visible fields to build the
parts of what I want and then I combine them into my
visible field.

I notice that I can pull up the "code" window. Is there a
way to place all my code in one function in the code
window and then place the results in my visible field or
is there a better way to handle my code.

Thanks for your response,
Tim
 
I'm not quite certain what it is you want to do... but code placed in the
Print event of the Detail Section of the Report will be executed for each
Record (and, name aside, will be executed in Preview mode, too). That's more
efficient in most cases, than using the Format event, because Format may
fire more than once per record (particularly disconcerting if you are
accumulating totals in your code).

An alternative is to use a User-Defined-Function in the Control Source, make
this a calculated field, and do your calculation in the UDF.

Larry Linson
Microsoft Access MVP
 
Thanks Larry,

What I think you are saying is that I can bring up
the "code" window by clicking on the code icon and then
create my function and then call that function from
the "control source" of my field in the report.

If this is right, I could not get it to work. How do I
call the function from the control source? I could not
get past that.

Thanks,
Tim
 
Back
Top