R
Rod
I have a linked ODBC database that I have created some
crosstab queries, forms and reports for in Access. I have
a form on which the user selects the options they want to
select the proper query. The individual queries work fine
when run by themselves. When generated from within the
report all but two repeat the last record. The number of
repeats appears to be random (from 4 to 158). (If all of
the queries repeated the last record, I'd be able to track
the issue.)
I can watch the Detail_format event get called several
times after the last record from the query has been
processed. I addded the else code and that eliminates the
printing of the duplicate records but leaves a gap between
the last record and the report totals. Where the
duplicates were 158 this means the totals are several
pages later. Not a tenable solution. (The code is borrowed
from the Developers Solutions sample for the employee
sales crosstab report.) I could really use some
suggestions!!!! The code from the detail_fromat section is
below:
-----------------------------
Private Sub Detail_Format(Cancel As Integer, FormatCount
As Integer)
' Place values in text boxes and hide unused text boxes.
Dim intX As Integer
Dim lngRowTotal As Long
' Verify that not at end of recordset.
If Not rstReport.EOF Then
' If FormatCount is 1, place values from recordset into
' text boxes in detail section.
If Me.FormatCount = 1 Then
For intX = 1 To intColumnCount
' Convert Null values to 0.
Me("Col" + Format$(intX)) = xtabCnulls(rstReport
(intX - 1))
Next intX
'cntx = cntx + 1
'Debug.Print cntx
'cntx = 1
lngRowTotal = 0
For intX = strtclmn% To intColumnCount
' Starting at first text box with crosstab value,
' compute total for current row in detail section.
lngRowTotal = lngRowTotal + Me("Col" + Format$(intX))
' Add crosstab value to total for current column.
lngRgColumnTotal(intX) = lngRgColumnTotal(intX) + Me
("Col" + Format$(intX))
Next intX
' Place row total in text box in detail section.
Me("Col" + Format$(intColumnCount + 1)) = lngRowTotal
' Add row total for current row to grand total.
lngReportTotal = lngReportTotal + lngRowTotal
' Hide unused text boxes in detail section.
For intX = intColumnCount + 2 To conTotalColumns
Me("Col" + Format$(intX)).Visible = False
Next intX
' Move to next record in recordset.
rstReport.MoveNext
End If
Else
For intX = 1 To intColumnCount
Me("Col" + Format$(intX)) = Null
Next intX
For intX = intColumnCount + 1 To conTotalColumns
Me("Col" + Format$(intX)).Visible = False
Next intX
End If
End Sub
crosstab queries, forms and reports for in Access. I have
a form on which the user selects the options they want to
select the proper query. The individual queries work fine
when run by themselves. When generated from within the
report all but two repeat the last record. The number of
repeats appears to be random (from 4 to 158). (If all of
the queries repeated the last record, I'd be able to track
the issue.)
I can watch the Detail_format event get called several
times after the last record from the query has been
processed. I addded the else code and that eliminates the
printing of the duplicate records but leaves a gap between
the last record and the report totals. Where the
duplicates were 158 this means the totals are several
pages later. Not a tenable solution. (The code is borrowed
from the Developers Solutions sample for the employee
sales crosstab report.) I could really use some
suggestions!!!! The code from the detail_fromat section is
below:
-----------------------------
Private Sub Detail_Format(Cancel As Integer, FormatCount
As Integer)
' Place values in text boxes and hide unused text boxes.
Dim intX As Integer
Dim lngRowTotal As Long
' Verify that not at end of recordset.
If Not rstReport.EOF Then
' If FormatCount is 1, place values from recordset into
' text boxes in detail section.
If Me.FormatCount = 1 Then
For intX = 1 To intColumnCount
' Convert Null values to 0.
Me("Col" + Format$(intX)) = xtabCnulls(rstReport
(intX - 1))
Next intX
'cntx = cntx + 1
'Debug.Print cntx
'cntx = 1
lngRowTotal = 0
For intX = strtclmn% To intColumnCount
' Starting at first text box with crosstab value,
' compute total for current row in detail section.
lngRowTotal = lngRowTotal + Me("Col" + Format$(intX))
' Add crosstab value to total for current column.
lngRgColumnTotal(intX) = lngRgColumnTotal(intX) + Me
("Col" + Format$(intX))
Next intX
' Place row total in text box in detail section.
Me("Col" + Format$(intColumnCount + 1)) = lngRowTotal
' Add row total for current row to grand total.
lngReportTotal = lngReportTotal + lngRowTotal
' Hide unused text boxes in detail section.
For intX = intColumnCount + 2 To conTotalColumns
Me("Col" + Format$(intX)).Visible = False
Next intX
' Move to next record in recordset.
rstReport.MoveNext
End If
Else
For intX = 1 To intColumnCount
Me("Col" + Format$(intX)) = Null
Next intX
For intX = intColumnCount + 1 To conTotalColumns
Me("Col" + Format$(intX)).Visible = False
Next intX
End If
End Sub