Access 2010
Access 2003
Seminars
Tips & Tricks
Access Forum
Course Index Insider Circle
 
Tutorials   News   Tips   Forums   Help   Logon   Order  
 
     
 
Tips & Tricks

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

   

  Access   Excel   Word   Windows   FrontPage   Hardware   Misc

 

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?
 
A:
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;

Me.Refresh
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.

The
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.

The
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.

 

You may want to read these articles from the 599CD News:

 

 
Learn
 
Microsoft Access
Microsoft Excel
Microsoft Word
Microsoft Windows
Microsoft PowerPoint
Adobe Photoshop
Visual Basic
Active Server Pages
Online Seminars
More...
Customers
 
Account Login
Online Theater
Downloads
Lost Password
WalkThru Tutorials
Free Upgrades
Insider Circle
Info
 
Latest News
New Releases
User Forums
Tips & Tricks
Search Our Site
Waiting List
Production Schedule
Help
 
Live Chat
Customer Support
Troubleshooting
FAQs
TechHelp
Consulting Services
About Us
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Order
 
Video Tutorials
Handbooks
MYOLP Memberships
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Live Chat
General Contact Info
Support Policy
Contact Form
Email Us
Mailing Address
Phone Number
Fax Number
Course Survey
Try Us
 
Free Lessons
Online Theater
Mailing List
Course Indexes:   Microsoft Access   Microsoft Excel   Microsoft Word   Microsoft PowerPoint   Visual Basic (VB)   Photoshop   Active Server Pages (ASP)  
Keyword Search Cloud:   What's This?   courses   microsoft access tutorials   vlookup   access   cartesian   excel   dlookup   vba   attendance   access 2007   sql   windows 7   combo box   pivot table   visual basic   test   iif   word   calendar   query   conditional formatting   pivot tables   photoshop   hlookup   access 101   excel 202   excel 2007   student attendance   update query   my account   word 2007   append query   quickbooks   queries   dsum   reports   powerpoint   if   microsoft access   dmax   mail merge   relationships   ms access   access 2010   vb   dcount   subforms   excel 2003   handbooks   html   599cd   combobox   if function   security   microsoft word   after update  
Copyright 2012 by 599CD.com, All Rights Reserved