ACC2000: Subform Not Synchronized with Main Form in Microsoft Access Project (236368)
The information in this article applies to:
This article was previously published under Q236368 Moderate: Requires basic macro, coding, and interoperability skills.
This article applies only to a Microsoft Access project (.adp).
SYMPTOMS
When you move from record to record in a main form, the main form and the nested subform are not synchronized if either of the following conditions is true: - You are working in a Microsoft Access project that you created by running the Upsizing Wizard. When you upsized the original database, you chose the Create a new client-server application option.
-or-
- You manually created or modified the nested subform and set its RecordSource property to the name of a stored procedure.
CAUSE
The record source of the subform is a stored procedure.
RESOLUTION
Use a stored procedure with an input parameter as the record source of the subform, and then use the InputParameters property of the subform to supply information to the stored procedure. The following example uses the sample Access project NorthwindCS.adp to show you how to do this.
CAUTION: If you follow the steps in this example, you modify the sample Access project NorthwindCS.adp. You may want to back up the NorthwindCS.adp file and follow these steps on a copy of the project. Creating the Main Form- Open the sample Access project NorthwindCS.adp, which by default is located in the \Program Files\Microsoft Office\Office\Samples folder.
- In the Tables list, click Orders.
- On the Insert menu, click AutoForm.
- Save the form as Orders1, and then close it.
Creating the Stored Procedure and Subform- In the Database window, click Stored Procedures, and then click New.
- Replace any text in the Stored Procedure Designer with the following Transact-SQL statements:
Create Procedure "MyRecordSource"
@OrderId int
AS
SELECT * FROM "ORDER DETAILS" WHERE OrderId = @OrderId
- Save the stored procedure, and then close it.
- In the Stored Procedure list, click MyRecordSource.
- On the Insert menu, click AutoForm.
- Open the form that the AutoForm Wizard created in Design view, and set the DefaultView and ViewsAllowed properties of the form to Datasheet.
- Set the InputParameters property as follows:
@OrderId int = Forms!Orders1!OrderId
- Save the form as MyRecordSource, and then close it.
Adding the Subform to the Main Form- Open the Orders1 form in Design view, and click the Subform/Subreport control in the toolbox.
- Place a subform in the details section of the Orders1 form. When the Subform Wizard opens, click the Use an existing form option, and then click the MyRecordSource form.
- Save your work, and then open the Orders1 form in Form view.
- Open the Orders1 form and note that the main form and the subform are synchronized as you move from record to record in the main form.
REFERENCESFor more information about main forms and subforms, click Microsoft Access Help on the
Help menu, type subforms in the Office Assistant or
the Answer Wizard, and then click Search to view the topics
returned.
For more information about stored procedures and input parameters, refer to SQL Server 7.0 Books Online, which is available for download from the following Microsoft Web site:
Modification Type: | Minor | Last Reviewed: | 8/9/2004 |
---|
Keywords: | kbdownload KbClientServer kbprb KB236368 |
---|
|