ACC2000: Text Box in Form Header or Footer Displays Previous Record When You Move Through Records

ID: Q232294


The information in this article applies to:
  • Microsoft Access 2000

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

Novice: Requires knowledge of the user interface on single-user computers.


SYMPTOMS

A text box in a header or footer of a form displays the previous values as you move forward and backward through the records.


CAUSE

When you click the navigation buttons in Form view to move forward and backward through the records, a text box in the header or footer of the form displays the value of the previous record when the following two conditions are true:

  • The textbox in the header or footer has the focus as you move through the records.
  • The EnterKeyBehavior property of this text box is set to New Line in Field.


RESOLUTION

In the Current event of the form, use Visual Basic for Applications code to repaint the screen. To do so, follow these steps:

  1. Open your form in Design view.


  2. On the Edit menu, click Select Form.


  3. On the View menu, click Properties.


  4. In the Form property sheet, click the Event tab, click in the OnCurrent property box, click the Build (...) button, click Code Builder, and then click OK.


  5. Type the following code:


  6. 
    Private Sub Form_Current()
        Me.Recalc
    End Sub 
  7. Save your changes and view the form.



MORE INFORMATION

CAUTION: Following the steps in this example will modify the sample database Northwind.mdb. You may want to back up the Northwind.mdb file and perform these steps on a copy of the database.

Steps to Reproduce Behavior

  1. Open the sample Access database file Northwind.mdb or the sample Access project file NorthwindCS.adp.


  2. Click Tables under Objects, and then click the Shippers table.


  3. On the Insert menu, click AutoForm.


  4. On the View menu, click Design View.


  5. If the AutoForm Wizard included a subform in the design of the form, delete it.


  6. On the View menu, click Form Header/Footer.


  7. Click the CompanyName text box, and then click Cut on the Edit menu.


  8. Click in the form header section, and then click Paste on the Edit menu.


  9. Click the Phone text box, and then click Cut on the Edit menu.


  10. Click in the form footer section, and then click Paste on the Edit menu.


  11. Set the Height property of the detail section to 0.5".


  12. Hold down the SHIFT key, and then click in the CompanyName and Phone text boxes.


  13. Set the EnterKeyBehavior property to New Line in Field.


  14. On the View menu, click Form View.


  15. Move forward and backward through the records and note how the CompanyName and Phone values change accordingly.


  16. Move back to the first record, and then place the mouse pointer in the CompanyName text box.


  17. Move forward and backward through the records and note how the CompanyName value remains out of synch by one record.


Additional query words: prb

Keywords : kbdta
Version : WINDOWS:2000
Platform : WINDOWS
Issue type : kbprb


Last Reviewed: September 14, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.