Solved refresh page [form]

TipsyWolf

Member
Local time
Today, 22:17
Joined
Mar 20, 2024
Messages
249
hey guys,
is there a way to code on click event to refresh (F5) current form ?
sorry for simple question, couldn't find on the internet.
 
It depends what you want to do. There is a recalc, refresh, repaint, requery all doing slightly more things.

me.recalc
me.refresh
me.repaint
me.requery

I would start with me.refresh because it will not move to a different record. However if you need to show additions or deletions you need the requery.

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

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.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom