Code To Use At Form And Report (1 Viewer)

Ashfaque

Student
Local time
Today, 10:51
Joined
Sep 6, 2004
Messages
894
Hello,

I have some working code in a Sub xxx() for the graph that placed on a form. This code was used for chart.
The same chart I have placed on the report to send it concerned authorities in pdf.

The graph in report is ok but some calculated figures which are appearing in the form are not appearing in the report. Those calculated figures will appear surely in the report also if I copy code lines of form and place in report events. The thing is code is lenthy and dont want to make my report heavy.

So my question is how to place my code in a public module and just call it on form and report. so this way I can copy same code lines at form and report.

I haven't yet placed my own created code in a Public module so need your support.

Thanks,
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 22:21
Joined
Oct 29, 2018
Messages
21,515
Just create a Standard Module and start with something like:
Code:
Public Function FunctionName() As Variant
'your code in here
End Function
You can then call your function from anywhere.
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 06:21
Joined
Jul 9, 2003
Messages
16,306
Those calculated figures will appear surely in the report also if I copy code lines of form and place in report events.

Not necessarily, because the report events don't operate as you would expect. I'm not well up on reports, but some of the events do not paint/build the report when the report is called. I understand the only event that can paint/build the report is the on open event. I'll say no more, because I don't know enough about it! I do know how I work around this problem...

What I do is build all the information in the form, then store the information in Custom Properties within the Form. When the Report opens the "Report On Open Event" has access to the information stored in the Form, stored within the Forms Custom Properties. The information is then distributed to the Report Controls and Properties, where it is required.

For example:-
  • You can set the reports record source
  • You can set the reports caption
  • You can place dates in labels and text boxes.

I don't know if you can directly access the chart object, though, I assume there must be some way.

For a better explanation see my blog on my website here:-


If you want a Free copy of my demonstration database use Discount Code:- aujx6tr for 100% discount...

When the discount expires, please contact me via this forums PM (private messaging system)
 
Last edited:

Users who are viewing this thread

Top Bottom