Shift-F9

G

Guest

Hi, I'd like to get a button to do what SHIFT-F9 does, refreshes a form with new records. Is it possible to make a command button do that sort of thing
Thanks
 
S

StCyrM

Check out the SendKeys command. As much as I hate to use SendKeys, sometimes
you have to.
 
G

Guest

SendKeys "+{F9}", True

I tried this but it doesn't seem to work. Any suggestions?

Thanks
 
A

Albert D. Kallal

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top