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

Global variable being reset

Status
Not open for further replies.

PeteWalburn

Programmer
Jan 13, 2004
63
GB
Hello,

I have a global variable gintPOs which is initially 0.

In my report I have a SubReport which contains a Sequential Section. In the Sequential Section are 2 Content sections. In the OnRow event of the first Content section I increment the global variable.

In the After frame of the SubReport I display the global variable, but it is always reset before the display of it.
My code does not set the variable to 0 anywhere, so why does it have a 0 value in it? When I step through in debug mode I can see that it is incremented as expected for each row displayed.

So why is the variable reset (presumably when the Sequential Section is exited)?

Pete
 
You might not be displaying the right variable. Try msgbox'ing the value inside that frame and see what it comes up with.
 
I am definitely displaying the right variable. I have been informed that the After frame is called before the Sequential Section and this is why the variable has 0 in it.

I have modified the control showing the count to have a Value Exp - Count() and it seems to display the correct value.

Thanks,

Pete
 
I'm having the same problem but I'm trying to put a row count for a subreport at the end of the report. count() won't do it - it diplays the row count for the outer report, not the subreport. Any ideas?

Thanks!
 
What I have done for similar situations is:

Make a global variable for the Count.
In the BuildFromRow function of one of the controls (or probably the OnRow function of the frame) add code to increment the global variable.
Add a frame to the After section and add a control to the frame to display the count in.
Override the BuildFromRow function of the control to be something like:
Function BuildFromRow(row As AcDataRow) As AcBuildStatus
BuildFromRow = Super::BuildFromRow(row)
' Insert your code here
DataValue=Format(globalVariable,"Fixed")
End Function

I hope that this is of some help.

Pete
 
Thanks, I think I found another solution but this might help as well. What I did was to set the dynamictextcontrol, that I was assigning the variable to, to valuetype summarycontrol. I was trying to figure out how any kind of count info could work if this control was indeed instantiated before the datarows were populated and then I relalized what the valuetype did (I think). It appears to work, but I can see that the "fixed" format might be useful as well.

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top