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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Coding Question

Status
Not open for further replies.

fredk

Technical User
Jul 26, 2001
708
US
I am going to try to break this down - I am using the following code in a status footer section - I can't simply put the code in the field as there are multiple fields depending on the data output by the query - My code in the On Print event of the status footer is:

For intx = 3 To intcolumncount
If Me.Col1 = "rel to mkt" Then
Me("stat" + Format(intx)) = Me("col" + Format(intx))
End If

The problem that I have is there are three lines in the detail section under the status of "rel to mkt" (along with about 5 other status types) my code only returns the total of the last line that contains a status of "rel to mkt" - I am trying to return the total of all three boxes that contain "rel to mkt"

so the report detail looks like:

Status Result Qrt 1 Qrt2
declined not rel 10 12
In Und pending 15 11
On Hold pending 12 9
Rel To mkt Lost 9 7
Rel To mkt Pending 3 4
Rel To mkt Sold 8 3

My code results in totals of 8 and 3 - instead of totalling all "rel to mkt" (20 and 14)
Thanks for the help!!!
 
Fred,

Use the Header_OnPrint to init to 0.
Use the Detail_OnPrint to add to totals.

 
Thanks for the help! Can you elaborate a little (I am new to this) thanks!!!!!!
 
Fred,

I only have a few minutes, so here goes ...

You can put some unbound controls on your footer section.
They will not be populated by your report's source.

As each page formats and prints the header, detail section
and footer, events fire.

You can use the Header_OnFormat event to set the unbound
controls to 0:

Me.txtUnboundControlQ1 = 0
Me.txtUnboundControlQ2 = 0

As each detail line prints (not formats), you can use
the Detail_OnPrint event to do:

If Me.txtStatusField = "Rel To Mkt" then
Me.txtUnboundControlQ1 = Me.txtUnboundControlQ1 +
Me.Qrtr1
Me.txtUnboundControlQ2 = Me.txtUnboundControlQ2 +
Me.Qrtr2
End If

When the footer prints, you should have the values
that you want.

good luck,
Wayne
 
Wayne, got it - thanks for your help, I appreciate it!!!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top