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!

Grand Total IntegerControl

Status
Not open for further replies.

MaumeeScott

Technical User
Jan 29, 2004
25
US
I have the following method on an integer control in the content section of a report. This essentially calculates how many of these fields are null and returns the number. This works fine. What I now need to do is to Average this in the report after section and I can't seem to get it to work. Thanks in advance for any and all responses.

Sub OnRow( row As AcDataRow )
Super::OnRow( row )
Dim NullCount As Integer
NullCount = 0
if IsNull(row.getvalue("location.glaccout")) then let NullCount = NullCount + 1
if IsNull(row.getvalue("location.region")) then let NullCount = NullCount + 1
if IsNull(row.getvalue("location.state")) then let NullCount = NullCount + 1
if IsNull(row.getvalue("location.postalcode")) then let NullCount = NullCount + 1
datavalue = NullCount
End Sub

Thanks,
Scott
 
You can try this:

1. Create a double control in the After Slot frame to hold the average value.

2. Create a static variable called NullCount in that control
Name: NullCount
Type: Integer
Storage: Static
Visibility: Public

3. Specify Count() in the ValueExp property, to find the number of rows. THIS IS IMPORTANT.

4. Override the OnRow method of that control as follows:
Sub OnRow( row As AcDataRow )
Super::OnRow( row )
if IsNull(row.getvalue("location.glaccout")) then let NullCount = NullCount + 1
if IsNull(row.getvalue("location.region")) then let NullCount = NullCount + 1
if IsNull(row.getvalue("location.state")) then let NullCount = NullCount + 1
if IsNull(row.getvalue("location.postalcode")) then let NullCount = NullCount + 1
End Sub

5. Override the Finish method of the control as follows:

Sub Finish( )
Super::Finish( )

' Calculate the average,
' it will be zero if Count() is zero.
DataValue = SafeDivide(NullCount,Datavalue, 0)

End Sub

I hope this helps.

-- JB
 
John,
That worked great! Thanks! Would the same process be used to find the Maximum value of that same variable?

Thanks again!

Scott
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top