When applying Microsoft Entry, many newbie builders have problem understanding the variation among Me.Refresh and Me.Requery. So, let us consider a glimpse at the variations between the two.
This is the brief edition:
Each Refresh and Requery help you save any variations built to the recent file, having said that…
Me.Requery pulls all new info from the fundamental table or query, including new additions and deletions
Me.Refresh only updates the information in the existing variety, but will not show new or deleted records.
Here is the prolonged variation:
Me.Requery forces the entire recordset (fundamental info) for the form to reload. This suggests ALL of the records in your present form will reload. Your present-day place will be shed, so if you might be sitting on report 10 of 100, you may come across you again on the initial file. Me.Requery is primarily the exact same as closing and reopening the kind. Any new data included by other concurrent consumers will be obtainable. Also any records that have been deleted will vanish. Requery in essence “re-operates the query” that pulled the information into the form in the 1st spot. You can also use requery to update the facts in a checklist box or combo box.
Me.Refresh will save the present-day report that you happen to be functioning on. It will also retrieve any modifications (but not additions or deletions) to any records revealed in the present form. Any calculations on the sort (unbound fields) are recalculated. Refresh does NOT reload the recordset. You do not get rid of your situation in the type (you remain on the present file). Any new information included by other end users will not be shown.
If you want to open up a different type or, especially, a report that contains the facts on the latest form, you need to have to issue a Me.Refresh command. I do this in my tutorial when we build the bill primarily based on the present get. You need a Me.Refresh to help you save the data to the table so that it will print the right way. You could not use Requery simply because it will place you back on history 1 of the recordset, which could not be what you want.
There are also two other commands that get puzzled with refresh and requery a ton: Repaint and Recalc.
The Me.Repaint command only redraws the latest kind and all of its controls on the display. This is specifically practical when you happen to be functioning a type with timers and extensive celebration loops and you want to pressure a thing on the screen (probably a counter) to update as the occasion is functioning, so the person does not just sit there hunting at absolutely nothing taking place. Repaint would not influence facts.
The Me.Recalc command forces all of the calculated controls on the kind to be reevaluated. For illustration, if you’re just exhibiting Objects * UnitCost in a text box, and it really is not updating, you could use Me.Recalc to power it to update. I have hardly ever truthfully Had to use Recalc before. Entry is fairly very good about recalculating immediately.
In my tutorials, I deal with the Refresh command in a whole lot of various areas. I commence by showing you the Refresh macro command in Obtain 204. We then see it as a VB command in Entry 302. I deal with Requery in Obtain 206, 306 and 307. As of proper now, I haven’t had to use Repaint or Recalc in any of my tutorials. Once more, they’re pretty unusual, but they’re available if you want them.