Microsoft KB Archive/223222

= ACC2000: Form's Controls Empty after Recordset.Requery =

Article ID: 223222

Article Last Modified on 12/12/2002

-

APPLIES TO


 * Microsoft Access 2000 Standard Edition

-



This article was previously published under Q223222



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
If you use the Requery method of the Recordset object to requery a form, you no longer see all the records in the form. If you are using a Microsoft Access database, you find that the first record is the only record appearing in the form. If you are using a Microsoft Access Project, "Name?" appears in all the fields and you can no longer see any records in that form. In either case, the form does not show all records, but the records themselves are unharmed.



RESOLUTION
Do not use the Requery method of the Recordset object to requery a form; instead, reset the RecordSource property.

For example, if your code reads Form1.Recordset.Requery change it to: ' Clear the RecordSource property Form1.RecordSource = "" Form1.RecordSource = "" where  is the name of the record source.



STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.



Steps to Reproduce Behavior
CAUTION: If you follow the steps in this example, you modify the sample database Northwind.mdb. You may want to back up the Northwind.mdb file and follow these steps on a copy of the database.

 Open the sample Access database file, Northwind.mdb, or the sample Access Project file, NorthwindCS.adp. Open the Categories form.  Add a command button to the form with the following properties:   Command button --  Name: RequeryRec Caption: Requery Recordset   Set the OnClick property of the new RequeryRec button to the following event procedure: Private Sub RequeryRec_Click Me..RecordSource = "" Me.RecordSource = "Categories" End Sub </li> View the form in form view and click the RequeryRec button two times.

If you are in the Access database file, Northwind.mdb, note that the first record appears normal. However, you cannot navigate to any other records. The Navigation bar displays the record count as "Record 1 of 1.".

If you are in the Access Project file, NorthwindCS.adp, note that "?Name" appears in all the fields. The Navigation bar displays the record count as "Record 1 of 1.".</li></ol>

<div class="references_section">