I have a main form that stays open all the time. Sometimes I change the data on other forms that are reflected on this main form and need it to display the latest data when it has the focus again.
What event should I use and code to do this?
RESOLVED:
Thanks,
Refresh form data
-
- 4StarLounger
- Posts: 550
- Joined: 30 Jul 2014, 23:58
Refresh form data
Last edited by burrina on 29 Jan 2017, 21:51, edited 1 time in total.
-
- Administrator
- Posts: 78596
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Refresh form data
You could use the On Got Focus event of the form. If you have merely modified existing records, you can use the Refresh method; if you may have added or removed records, use the Requery method. For example:
Remark: because the Requery method loads the record source of the form again from scratch, the form will jump to the first record by default.
Code: Select all
Private Sub Form_GotFocus()
Me.Refresh
End Sub
Best wishes,
Hans
Hans
-
- 4StarLounger
- Posts: 550
- Joined: 30 Jul 2014, 23:58
Re: Refresh form data
The form is unbound, only some data on it uses either an expression or DLookup.
-
- Administrator
- Posts: 78596
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands