report- help with calculated field from text box on form

pizaccess

New member
Local time
Today, 13:56
Joined
Dec 24, 2001
Messages
8
Is there any way you can have a value from a calculated text box on a form appear on a report without having that form open?

I am trying to generate a report. The report is derived from a number of tables so I put together a query. One of the forms frmCharges has multiple text boxes and combo boxes to generate a total. I want this txtTotal box to appear on my report amongst other things. Since its a calculated text box not having a control source to a tbl I can't get this value to appear in a query. I don't know how to deal with this.

Can you give me some direction. Do I need to redo the form and base it on a query and place all calculations in the query. And if so how do I deal with combo boxes on a query. Or is there a simpler way of dealing with this.

Looking through old ques I came across something similar but it was said that the form had to be open and on that record to pass it through. This will not work for what I'm trying to do, because the report is a summary of different totals for different jobs over different records
 
You'll need to recalculate the value for the report. You can put the calculation in a public function in a standard code module so the same code can be used by both the form and the report.
 
Thank You for your response.

I'm a little unclear as to how to write a public function. I've only really done private functions and attached them to events. In a public function do I still attach it to an event. It seems like you would have to but how would the report pick up the value. If at all possible could you show me the structure. This would be very much appreciated. I've been looking through books trying to figure it out and there isn't much on this in them. I'm pretty confident I can write the calculation though.

Thank you much
 
A public function is simply a function that can be accessed by any part of your database. For instance, there is a function in my database called fOSUserName() which I use to get the logon name for the current user. It is defined largely the same as a Private Function, except that you create its own Module for it (the name of the module is irrelevant). You also change the Private to Public when you write it, of course.

Whenever I need it, including in an event procedure, I just call the function by name and go on about my business. An example is:
Private Sub Form_BeforeUpdate()
Me.LastModified = Now()
Me.ModifiedBy = fOSUserName()
End Sub

HTH,
David R
 

Users who are viewing this thread

Back
Top Bottom