No data appears in a subreport when the subreport is linked by an AutoNumber field with the Field Size property set to Replication ID (824641)
The information in this article applies to:
- Microsoft Office Access 2003
- Microsoft Access 2002
- Microsoft Access 2000
SYMPTOMSIn a Microsoft Access database, if you view a report in the
Print Preview mode that is linked to a subreport by using an AutoNumber field, and if the Field Size property of the field is set to Replication ID,
the subreport may not display any data.CAUSEThe Datasheet view of a table or a query that contains a
field of data type AutoNumber (with its FieldSize property set to Replication ID) returns or displays the Replication ID as a string, instead of
returning or displaying the Replication ID as a GUID.WORKAROUNDTo work around the problem, use one of the following
methods:
Method 1: Use a Subform Instead of a SubreportCreate a subform where the subform is based on the same recordset
as that of the existing subreport, and then link the created subform instead of
the subreport to the main report. To do this, follow these steps:
- Add a form that is based on the same recordset as the
subreport.
- Open the main report in the Design view.
- Insert a Subform/Subreport control to the report from the Toolbox.
- In the SubReport Wizard, click to select Use an
existing report or form, and then click the name of the form that was
created in step1 from the list box.
- Click Next.
- Under Form/report fields, select the AutoNumber field in the main report.
- Under Subform/subreport fields, select
the corresponding field in the subform that was created in step 1.
- Click Finish. Notice that the data in
the subform appears when you view the main report in Print Preview.
Method 2:
Modify the Record Source of the ReportsYou can modify the record source of the main report and the
subreport to use queries so that the corresponding query returns all the
columns from the relevant table. Additionally, the queries must use the CStr function to convert the contents of the Replication ID field to a string value. To do this, follow these steps:
- Create a query for the record source of the main
report.
For example, assume that the source of the main report is a
table that is named Project. The Project table contains two fields, PID and PName. In this example, PID is an AutoNumber field with the Field Size property set to Replication ID. Create a query that is named Query1 that is similar to the following query:SELECT
CStr([PID]) AS strPID,
PName
FROM
Project - Create a query for the record source of the
subreport.
For example, assume that the source of the subreport is a
table that is named Tasks. The Tasks table contains two fields, TaskID and RelatedProject. In this example, RelatedProject is a Number field
with the Field
Size property set to Replication ID
that references the PID column of the Project table. Create a query that is named Query2 that is similar to the following query:SELECT
TaskID,
CStr([RelatedProject]) AS strRelatedProject
FROM
Project - Create the main report that is based on the Query1 query.
- Open the main report in Design view.
- Insert a Subform/Subreport control in the report from the Toolbox.
- In the SubReport Wizard, click to select Use
existing Tables and Queries,
and then click Next.
- Click Query: Query2 in the
Tables/Queries list.
- Click >> to move all fields from
the Available Fields list to the Selected Fields list,
and then click Next.
- Under Form/report fields, select
strPID.
- Under Subform/subreport fields, select
strRelatedProject.
- Click Finish. Notice that the data in
the subreport also appears when you view the main report in Print
Preview.
REFERENCES
For more information about the AutoNumber data type and Replication
ID, click Microsoft Office Access Help on the Help menu, type about autonumber field size and replicated databases in the Search for box in the Assistance pane, and then click Start searching to view the topic.
For more information, click the following article number to view the article in the Microsoft Knowledge Base:
210612
Parameter query returns no records with Replication ID field
Modification Type: | Minor | Last Reviewed: | 8/29/2006 |
---|
Keywords: | kbDatabase kbReport kbprb KB824641 kbAudDeveloper |
---|
|