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!

"Report sections do not match data source"?

Status
Not open for further replies.

Jerrycurl

Programmer
Aug 4, 1999
85
US
In VB6, I have a recordset Rs1 that holds the records returned from this query:<br>
<br>
SELECT o.occupation_code, o.occupation_title, oc.category_name <br>
FROM OCCUPATION o, OCCUPATION_CATEGORY oc <br>
WHERE oc.category_num = o.category_num and o.occupation_title like '%farmer%' and o.occupation_title like '%%' and o.occupation_title like '%%' and substring(o.occupation_code,1,3) like '%' and substring(o.occupation_code,5,3) like '%' and substring(o.occupation_code,9,3) like '%' order by oc.category_name ASC, o.occupation_title ASC<br>
<br>
The records are displayed in a grid. I need to allow the users to print the records as well. Since the grid can't print itself, I want to use the recordset as the datasource of a datareport and print that. This works when I just have the category_num and the occupation_title in the detail section of the datareport. But I want to group the results by the category_name. As soon as I add a group header section to the datareport, even without adding any controls to it, when I try to show it I get the error &quot;Report sections do not match data source&quot;. This seems like it's being much more difficult than it should be. Anyone have any suggestions?
 
I have MSDN which appears to be the Help that comes with VB5 and VB6 now.<br>
Anyway there are several help topics that show how to use the Data Environment. (Click Projects, Data Environment)<br>
<br>
Look this up “Creating a Simple Data Report” in the Visual Basic documentation section.<br>
I went step by very slow step and created a report using it.<br>
Now It (Data Environment) might be what you need to do first then connect the data grid to it and also make a report from it.<br>
Or<br>
Add a Data Environment to handle the report and use your existing method to handle the grid.<br>
<br>

 
Hi I have the same error problem as jerrycurl, did someone sorted this out? I am not using DE(Data Environment) to create the report. Hi DougP, I've seen the MSDN, but it did not help me sort out the problem, any other suggestions?
 
Hi guys

this article describes what you are talking about


SYMPTOMS
When you use a Report Control that is bound to a Visual Basic Data Environment command object and perform a GroupBy, you receive the following error:

8570 Report sections do not match data source
CAUSE
One of the following has occurred:
The DataReport is bound to an ungrouped recordset.
The DataReport was created before binding the recordset.
RESOLUTION
The ADO Command object that the report is based on needs to be modified for grouping. Below is an example using Visual Basic 6.0's Data Environment and grouping in a report. Note that the command is doing the grouping, NOT the DataReport.
Create a new Standard EXE project. Form1 is created by default.
Add a reference to Microsoft ActiveX Data Objects 2.x Library.
Add a DataEnvironment.
Configure the Connection1 properties to use OLE DB Provider for SQL Server (SQLOLEDB) and the Northwind database (Nwind.mdb).
Add a Command object off of Connection1.
Configure the Command1 properties to use the Orders table and group by OrderDate (under the Grouping tab).
Add a DataReport to your project.
Set the DataSource to DataEnvironment1.
Set the DataMember to Command1_Grouping.
Right-click on DataReport1 and choose Retrieve Structure.
From the Summary Fields in Command1_Grouping, click and drag the OrderDate field into the DataReport1 Group Header.
Click and drag detail fields from the Detail Fields in Command1 into the DataReport1 Detail section.
Add a CommandButton to Form1.
Add the following code to Form1:
Private Sub Command1_Click()
DataReport1.Show 1
Unload DataReport1
End Sub

Run the project and click Command1.
It is important that the report sections match the command object's structure. If the error continues to occur, try using the Retrieve Structure command on the DataReport to refresh the sections. Retrieve Structure will remove all fields that are currently in the DataReport.


Hope this helps!

Transcend
 
Hi Transcend

I've already seen that section from microsoft. This does not help as I am not using the Data Environment to create a report. Please see my codes below. I also got the idea from Microsoft, the codes seems alright except when I need to put details on other section of the report. I get the error &quot;Report sections do not match data source&quot;. Any more suggestions on how to tackle the problem? I'm really stuck on this part of VB. Please help.... help.... help....

Private Sub cmd_viewprint_Click()

Dim q As Integer
Dim intCtrl As Integer
Dim x As Integer
Dim z As Integer

Dim t
cn.Open &quot;PROVIDER=Microsoft.Jet.OLEDB.4.0;Data _ Source=d:\BILLADJ\BillingDB.mdb;&quot;

t = InputBox(&quot;test&quot;)
With cmd
.ActiveConnection = cn
.CommandType = adCmdText
.CommandText = <MYSQL>
.Parameters(0).Value = t
.Execute
End With

With rs
.ActiveConnection = cn
.CursorLocation = adUseClient
.Open cmd
End With

x = 0
q = 0
z = 0

With DataReport2
.Hide
Set .DataSource = rs
.DataMember = &quot;&quot;
With .Sections(&quot;Section4&quot;).Controls
For intCtrl = 1 To .Count
If TypeOf .Item(intCtrl) Is RptTextBox Then
.Item(intCtrl).DataMember = &quot;&quot;
.Item(intCtrl).DataField = rs(z).Name
z = z + 1
End If
Next intCtrl
End With

With .Sections(&quot;Section1&quot;).Controls
For intCtrl = 1 To .Count
If TypeOf .Item(intCtrl) Is RptTextBox Then
.Item(intCtrl).DataMember = &quot;&quot;
.Item(intCtrl).DataField = rs(z).Name
z = z + 1
End If
Next intCtrl
End With


.Refresh
.Show
End With

End Sub
 
You aren't using the dataenvironment ... but you are using a datareport.

I'm not really familiar with datareports as I use crystal for my reporting ...

Have you tried putting grouping in your recordset?

Transcend
 
hmmm maybe you have a point there. but yes, you can do data report w/o using DE, I have consumed most of my time using the DE in creating a report but have no success, as I have problems passing the values on a parameter. but first, I have to see if I can group my recordset (sorry I'm a newbie when it comes to this) :)
 
hello

i'm still having problems with the data report. Transcend, will you be able to provide me an example of creating a report using the Data Environment with an option of passing a parameter value? as I need to control the output in the report...
 
Hi there

sorry but as I said earlier, where I work we dont use the Data Environment at all so I'm not familiar with it ... we use crystal reporting.
Try looking again at technet

this one may be useful ...
do a search on technet for 'datareport' and it may help out.

Sorry I couldn't be more help

Transcend
 
thanks for trying Transcend, your help is very much appreciated.

Anyone out there still have any ideas???
I'm really stuck here %-)
 
You might like to check out

thread222-148876

its has info about a datareport using paramters ...

Transcend
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top