Microsoft KB Archive/256853

= ACC2000: Recordsets May Differ for a Data Access Page Depending on How You Build the Page =

Article ID: 256853

Article Last Modified on 6/24/2004

-

APPLIES TO


 * Microsoft Access 2000 Standard Edition

-



This article was previously published under Q256853



Moderate: Requires basic macro, coding, and interoperability skills.

This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).



SYMPTOMS
The method that you use to build a grouped data access page influences the type of recordset that is created for the page. There are three possible underlying recordsets. The difference among these recordsets is in the type of relationship that is created between the tables used in the record source. The number of records may also differ among these recordsets.



CAUSE
This behavior is by design. It allows you to decide which type of join the page is based on without creating an underlying query.



MORE INFORMATION
There are four methods that you can use to create a grouped data access page. They are:
 * Dragging fields from the field list to the page
 * Using the Group by Table feature
 * Using the Page Wizard
 * Using the Group by Promote feature

The first two methods create identical recordsets. The other two methods create a second and third type of recordset. These different recordsets are created even when the respective pages are based on the same tables.

The number of records returned by the pages is directly effected by the method that you use to build the page. The only way that you can determine the underlying recordset for a page is to retrieve this value programmatically. Visually, you cannot really determine how a completed page was built. Additionally, after you have built a page, there is really no good way to change the underlying recordset. Therefore, if you want to change the underlying recordset, you must rebuild the entire page.

The following four examples describe the different methods that you can use to create a grouped data access page. The examples also show the recordset that results from each method, including the number of records returned. Each example uses the Customers and Orders tables in the sample database Northwind.mdb as the source for each page.

Method 1: Dragging Fields from the Field List to the Page
 In the sample database Northwind.mdb, click Pages, and then click New. In the New Data Access Page dialog box, click Design View, and then click OK. If the field list is not displayed, click Field List on the View menu. Drag the following fields from the Customers table from the field list to the Unbound section of the page:

CustomerID

CompanyName

 Drag the OrderID field from the Orders table from the field list to the bottom of the page section until the mouse pointer changes to a line with arrows on each end. After you drop the field, a new section called Header: Orders is created, and the OrderID field is placed in this section. Drag the OrderDate field from to the Orders table from the field list to the Header: Orders section.</li></ol>

This drag-and-drop method creates the following record source, which returns a total of 91 records:

SHAPE

{ SELECT [CustomerID], [CompanyName] FROM [Customers] } AS [Customers]

APPEND ( { SELECT [OrderID], [CustomerID] AS [CustomerID1], [OrderDate] FROM [Orders]

WHERE ([CustomerID] = ?) }

AS [Orders]

RELATE [CustomerID] TO PARAMETER 0 ) AS [Orders]

Method 2: Group by Table
<ol> In the sample database Northwind.mdb, click Pages under Objects, and then click New.</li> In the New Data Access Page dialog box, click Design View, and then click OK.</li> If the field list is not displayed, click Field List on the View menu.</li> Drag the following fields from the Customers and Orders tables from the field list to the Unbound section of the page:

CustomerID

CompanyName

OrderId

OrderDate

</li> Select the CustomerID field on the page, and then click the Group By Table button. Note that two sections are created on the page: the Header: Customers and the Header: Orders sections.</li></ol>

The Group by Table method creates the following record source, which returns a total of 91 records:

SHAPE

{ SELECT [CustomerID], [CompanyName] FROM [Customers] } AS [Customers]

APPEND ( { SELECT [OrderID], [CustomerID] AS [CustomerID1], [OrderDate]

FROM [Orders]

WHERE ([CustomerID] = ?) }

AS [Orders] RELATE [CustomerID] TO PARAMETER 0 ) AS [Orders]

Method 3: Page Wizard
<ol> In the sample database Northwind.mdb, click Pages under Objects, and then click New.</li> In the New Data Access Page dialog box, click Page Wizard, click Customers as the table on which to base the page, and then click OK.</li> In the Page Wizard dialog box, add the following field to the page:

CustomerID

CompanyName

</li> Change the name in the Tables/Queries box to Table: Orders, and then add the following fields:

OrderID

OrderDate

</li> Click Next, choose to group by CustomerID, and then click Finish.</li></ol>

The Page Wizard method creates the following record source, which returns a total of eighty-nine records:

SHAPE

( SHAPE {SELECT [Customers].[CustomerID], [Customers].[CompanyName], [Orders].[OrderID], [Orders].[OrderDate]

FROM ([Customers]

INNER JOIN [Orders] ON [Customers].[CustomerID] =[Orders].[CustomerID]) } AS [CustomersWiz] )

COMPUTE [CustomersWiz] BY [CustomerID] AS [GroupOfOrders-CustomerID]

Method 4: Group by Promote
<ol> In the sample database Northwind.mdb, click Pages under Objects, and then click New.</li> In the New Data Access Page dialog box, click Design View, and then click OK.</li> If the field list is not displayed, click Field List on the View menu.</li> Drag the following fields from the Customers and Orders tables from the field list to the Unbound section of the page:

CustomerID

CompanyName

OrderId

OrderDate

</li> Select the CustomerID field on the page, and then click the Promote button. Note that a new section named Header: Orders-CustomerID is created on the page.</li></ol>

The Promote method creates the following record source, which returns a total of eighty-nine records:

SHAPE

( SHAPE { SELECT [Orders].[OrderID], [Orders].[CustomerID] AS

[CustomerID1], [Orders].[OrderDate], [Customers].[CustomerID],

[Customers].[CompanyName]

FROM [Orders]

LEFT OUTER JOIN [Customers] ON [Orders].[CustomerID] =

[Customers].[CustomerID] }

AS [Orders] )

COMPUTE [Orders] BY [CustomerID] AS [GroupOfCustomerID], [CompanyName] AS

[GroupOfCompanyName]

Additional query words: prb

Keywords: kbdap kbprb KB256853

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.