Current Event

Forms in Access have always had a Current event. Every time you move to a new record, the Current event fires to notify your form that it has moved. You can use the Current event to apply custom formatting to a field, or to hide or show controls based on data in the form.

Until Access 2007, reports were not interactive. You could open a report, view it on the screen, and print it, but you couldn't interact with it, and you certainly couldn't move from record to record. Access 2007 adds the capability to interact with report data. You can browse from record to record, click in individual rows in your report, and drill down into the data. With the new interactivity, Microsoft added the Current event so that your code can know when a user has clicked into a row on your report.

There is one difference between the Current event in a report and the Current event in a form. When you open a form, the Current event fires toward the end of the opening sequence of events because controls receive focus in forms and records are activated as a result. That is not the case with reports. Controls do not receive focus by default when you open a report, and the Current event does not fire. You can use the Load event of the report to set focus to a control, which will cause the Current event to fire when the report is opened. Naturally, because this event fires when a record on the report receives focus, it does not fire in Print Preview.

Use the SetFocus method of a control to set focus to it in the Load event.

0 0


  • klaudia bayer
    How to I set focus for the open event of a form in Access 2007?
    7 years ago

Post a comment