View the latest records for a form programmatically

Microsoft Office Access 2003

procedure.

ShowUse a macro

  1. To create a macro, open the form in Design view.
  2. Display the property sheet for the form or control on the form and then click the Event tab.

  3. Click the event property for the event that you want to trigger the macro.

    For example, to respond to a mouse click on a command button, open the button's OnClick event procedure.

  4. Click Build Button image next to the property box to display the Choose Builder dialog box.

  5. Double-click Macro Builder to display the macro window.

  6. Click Save Button image to save the macro.

  7. In a blank action row, click Requery in the action list.

    To update records for a control that is based on a table or query, set the Control Name argument to the name of the control.

    To update the records for the form as a whole, leave the Control Name argument blank.

  8. To test, run the macro by opening the form in Form view and performing the event that triggers the requery.

ShowUse Visual Basic code

  1. To open the event procedure for the appropriate event, open a form in Design view.
  2. Display the property sheet for the form or control on the form and then click the Event tab.

  3. Click the event property for the event that you want to trigger the procedure.

    For example, to respond to a mouse click on a command button, open the button's OnClick event procedure.

  4. Click Build Button image next to the property box to display the Choose Builder dialog box.

  5. Double-click Code Builder to display the event procedure window.

  6. Add the Requery method to the procedure for the form or control whose records you want to update. For example, to view the latest records in a combo box called CategoryID, add the following method to the procedure:
    CategoryID.Requery
    						
  7. To test, run the procedure by opening the form in Form view and performing the event that triggers the requery.