The following four methods can be found in Microsoft Access and have different uses:
- Access Requery
- Access Refresh
- Access Repaint
- Access Recalc
They can be split into two parts where the first two points handles records (the data) and the latter two the objects and their components (no data). Therefore you can start by answering the first simple question to help navigate to which part is best to use:
“Do I want to update data or components in my Microsoft Access database?”
Access Requery Or Not To Requery – That Is The Question: The Definitions
Using the Requery method you are calling a complete reloading of all records from the underlying table or query, This means for example when editing an existing record; say changing a first name to the current record as a simple example and you then call the Requery method, you actually update all records in the underlying data table or query which means if other records had either been updated, deleted and added they too will bind to the loading form (screen view of where you typically would edit data).
This is in effect a complete reload of the data (recordset to the form) and the cursor is repositioned to the first record of the updated recordset losing the current cursor’s position of the record just edit (if it were not the first record).
The Access Requery can be called not just for a form but for a control too like a ComboBox (drop-down box) which will reload the recordsource to that control.
For example, to reload a ComboBox control’s recordsource using VBA: Me.ComboBox1.Requery
Using the Access Refresh method is a more local version to Access Requery where it will not reload the entire recordset but only update and save the current record being edited.
This means no new additions or deletions will be seen as the underlying table or query is not reloaded. The other added benefit is that the current record’s cursor stays on the current record and doesn’t jump to the first record.
For example, to refresh the current form you use this simple VBA code Me.Refresh
The Access Repaint method is another way to say the screen is being refreshed or repainted. If you have a control like a counter or timer in order for it to change and update you will keep repainting the form. This automatically happens when you switch views or minimize and then restore a window but to keep the same screen and just update it, you simply call the following VBA code: Me.Repaint.
The Access Recalc method is used to recalculate expressions in controls (like a formula update). However, I would be surprised if you need to call this method as expressions that I’ve used automatically update and show the new result. But if for any reason you want to enforce this then using the VBA code: Me.TextBox.Recalc will recalculate the TextBox control containing an expression like “[Qty]*[UnitPrice]“.
To Access Requery or Not To Access Query – that’s the question and hopefully you now have a clearer understanding of the different methods available to you.
I would love to hear of your experiences from the above methods in the reply comments box below or you can of course email me.
Tags: access form requery, access record refresh, access requery, ms access recalculation, requery access
Using VBA code you can also call the DoCmd object which also uses the Requery method too. Additionally these methods can also be use in macros whether there are direct commands or called via a sub or function procedure in VBA.