Free Lessons
Fast Tips
Topic Index
Home   Courses   Seminars   Templates   TechHelp   Forums   Help   Contact   Join   Order   Logon  
Tips & Tricks

New Tips Added Weekly!
Click here to get on our Mailing List


Microsoft Access Requery v. Refresh

What's the difference between Me.Requery and Me.Refresh

Q: What's the difference between Me.Refresh and Me.Requery?
Here's the short version. Both Refresh and Requery save any changes made to the current record. However...

Me.Requery pulls all new data from the underlying table or query, including new additions and deletions;

only updates the records in the current form, but will not show new or deleted records.

Here's the long version:

Me.Requery forces the entire recordset (underlying data) for the form to reload. This means ALL of the records in your current form will reload. Your current position will be lost, so if you're sitting on record 10 of 100, you'll find yourself back on the first record. Me.Requery is essentially the same as closing and reopening the form. Any new records added by other concurrent users will be available. Likewise any records that have been deleted will disappear. Requery essentially "re-runs the query" that pulled the data into the form in the first place. You can also use requery to update the data in a list box or combo box.

Me.Refresh saves the current record that you're working on. It will also retrieve any changes (but not additions or deletions) to any records shown in the current form. Any calculations on the form (unbound fields) are recalculated. Refresh does NOT reload the recordset. You do not lose your position in the form (you stay on the current record). Any new records added by other users will not be shown.

If you want to open another form or, especially, a report that contains the data on the current form, you need to issue a
Me.Refresh command. I do this in my tutorial when we create the invoice based on the current order. You need a Me.Refresh to save the data to the table so that it will print correctly. You couldn't use Requery because it will put you back on record 1 of the recordset, which might not be what you want.

Yes, sometimes you'll hear me say "requery the results" in my classes, when I really mean "refresh." That's just a slip of the tongue.

There are also two other commands that get confused with refresh and requery a lot: repaint and recalc.

Me.Repaint command simply redraws the current form and all of its controls on the screen. This is especially useful when you're running a form with timers and long event loops and you want to force something on the screen (perhaps a counter) to update as the event is running, so the user doesn't just sit there looking at nothing happening. Repaint doesn't effect data.

Me.Recalc command forces all of the calculated controls on the form to be reevaluated. For example, if you're just showing Items * UnitCost in a text box, and it's not updating, you could use Me.Recalc to force it to update. I've never honestly HAD to use Recalc before. Access is pretty good about recalculating automatically.

In my tutorials, I cover the Refresh command in a lot of different places. I start by showing you the Refresh macro command in Access 204. We then see it as a VB command in Access 302. I cover Requery in Access 206, 306 and 307. As of right now, I haven't had to use Repaint or Recalc in any of my tutorials. Again, they're very uncommon.


By Richard Rost   Richard Rost on LinkedIn Email Richard Rost
Click here to sign up for more FREE tips




The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.

Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
My Account
My Courses
Lost Password
Student Databases
Change Email
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Customer Support
Web Site Tour
Consulting Services
Affiliate Program
Richard Rost
Free Lessons
Mailing List
Video Tutorials
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Terms of Sale
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

Copyright 2023 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 9/27/2023 9:03:50 PM.