Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Code behind report

Status
Not open for further replies.

IKinal

Technical User
Apr 14, 2003
32
US
Hi,

I need to generate a report with some complex logic, and I am trying to figure out whether it is possible to generate a section of a report programatically - I guess something like setting the control source of a text box to a VBA procedure. Is this possible in Access 2002?

Thanks,
I. Kinal
 
you can create a Function either in a class module or in the code window behind the Report, and then use that as the controlsource by entering
= TheFuctionName()

PaulF

 
Thanks, that seems to work. Now, what command do I use in the procedure to generate text in the original textbox?

I. Kinal
 
not sure what it is you are trying to accomplish. If you provide more information, I or someone else can probably assist you.

PaulF
 
I think he's trying to do the same thing I am, which is why I figure I'll post here instead of start a new thread. Basically I'm trying to use VBA to set the value of a text box (or maybe label?) before the report is generated. I have one report I'd like to have sorted 2 different ways, and rather than make up 2 separate reports with different sorting properties, I used the OnLoad command for the report and have it change the ordering there. Similarly I'd like to have a text box/label say "ordered by...", but It would have to change depending on what it's being ordered by.. I've tried coming up with some code on my own to do this, but so far to no avail... Any tips would be appreciated..

~Bob
 
Yep, that's the idea - I'm trying to get the code to generate text into a textbox. More completely, I'm trying to create a list of membership dues for people, which involves creating a line for each year of outstanding dues (based on the last paid date), and on that line there also needs to be the category of dues printed, and of course the sum which is a result of those two variables.

I. Kinal
 
I was looking around and I found this thread, which totally helped me out.. Hopefully it answers your question too. Good luck!

~Bob

thread703-424049
 
Thanks for the reference. Between that article and another one that I found, I figured it out. For anyone curious, The Vba code is simply textbox = "What you want to say", where textbox is the name of the textbox. Then I made that textbox unbound, and called the Event Procedure from the on Format event for the report detail.

I. Kinal
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top