Using sendkeys should be the LAST resort, and is generally a horrible
solution.
Sendkeys simply throws out keys to the windows operation system. You bump a
key, click the mouse, or any other application that pops up (like instant
messaging), or even a web browse will actually get those keystrokes. A very
very un-reliable approach to software development. Even just bumping the
mouse and selecting another form means the keystrokes go to some place were
you DO NOT expect them to go. You have such poor control, that as mentioned,
sendkeys should be the last, and final resort.
If you need to refresh the data, then of course the code behind the button
is:
me.Refresh
However, f9 does not actually do a refresh, but forces a re-calc, so, in
fact, the code to duplicate f9 should be:
me.Recalc
If you need to completely re-load the form, then you can use
me.Requery
Likely,what you are looking for is to re-calc (since that is what f9 does).
Note that shift-f9 does do a re-fresh.
I rarely have to use me.Recalc, but I use me.fresh a lot, since it forces
the current record to be written to disk, and will also show any updates to
records.
so,
me.requery = re-loads the whole form record set from scratch
me.refresh = write current record to disk, and re-load any changes to
records that are in the form (my favourite!)
me.ReCalc = forces the form to do a re-calc
me.Repaint = forces the form to re-draw.
DoEvents = lets all, or any of the pending events run.
For a few tips on "horrible" things that developers should NOT do, check out
the 10 bad list for ms-access at:
http://www.mvps.org/access/tencommandments.htm