Refreshing

Nicolette

Always Learning
Local time
Today, 14:55
Joined
Jun 26, 2010
Messages
178
How do I get Access to refresh automatically after a command is exicuted?
 
It depends what command you've executed? There's:

Me.Refresh
DoCmd.RunCommand acCmdRefresh

DoCmd.RunCommand acCmdRefreshData

Application.RefreshDatabaseWindow

The first two are the ones I believe you're enquiring about. You may also be referring to a Requery as well. So it all depends in which context you speak.
 
sorry I didn't realize there was more than one. I want to refresh after I Add, Delete, Or Edit a record but in the button command I don't know VB (i'm not ready for that yet LOL :eek:)so I would like to avoid it for now
 
Lol they aren't that many :)

Data is saved automatically (for bound controls) when you move to a different record. Actually, if you make a change on a control and move to another control the changes are recorded (or cached) until you close the form or move to another record.

So in essence you don't really need to refresh. If (however) you feel you do, then use Me.Refresh
 
well hat i'm running into is in my muliple items forms the changes are not showing unless i manually refresh or close and reopen
 
You also have a Refresh in your Tool Box.

in Form, Design View. Click on toolbox and add a Command Button to your Form. A wizard should appear and follow the prompts to make the button Refresh.
 
isn't there a way do do within the commands for the button that do the adding, deleleting and updating?
 
Yes. Make the button I suggested above.

In Design View, look at the vba code in this event. You should see one line line that you can copy and past into the vba event of the three buttons you mentioned.

This way, the three buttons will each do two tasks. They can do as many as you give them.
 
Nevermind, I made it so the Multiple Item form closes when an button is clicked then reopens after the user has updated or deleted a record. I like this better because I don't like having a ton of thing open at the same time.
 
Here is the VBA for a Refresh button I just added to a form.

PHP:
Private Sub CmdRefresh_Click()
On Error GoTo Err_CmdRefresh_Click


    DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70  'This line...

Exit_CmdRefresh_Click:
    Exit Sub

Err_CmdRefresh_Click:
    MsgBox Err.Description
    Resume Exit_CmdRefresh_Click
    
End Sub
The Red line should be what you see.

Copy and past this line into your other button's VBA Code and the button should also Refresh.

Put the line below the existing similar lines.

Copy your Form first, just in case it all turns to *$@!
 
Looks like you're using a much older version of Access, probably 97 PNGBill? The DoMenuItem command isn't used in newer versions, although it's only there for compatibility.
 
I don't get why you need to refresh though, I've never found the need to do that in my years of using Access, can you elaborate on what it is you're trying to do? You could be doing something wrong
 
Looks like you're using a much older version of Access, probably 97 PNGBill? The DoMenuItem command isn't used in newer versions, although it's only there for compatibility.

Using 2000 but may not have changed much from 97.
 
By the way (vbaInet should know this already) You want REQUERY NOT REFRESH!!!!
 
Yeap Bob, you have to follow by the OP's reques however, I did express that a requery could be what he/she requires (post #2).
... You may also be referring to a Requery as well. So it all depends in which context you speak.
 
Yeap Bob, you have to follow by the OP's reques however, I did express that a requery could be what he/she requires (post #2).

As this is a new user they would need to get an explanation of what the differences are between refresh and requery. It isn't always prudent to answer the exact question that an OP asks.

So, the answer is that

refresh - only refreshes changes to records that existed in the original query and so will NOT include new records added nor will it delete deleted records. This is especially important to realize in a multi-user environment.

requery - will show all changes made to records by others as well as INCLUDING new records added and removing records that have been deleted.

This is a very important concept to realize. Refresh is VERY RARELY what you want. Most of the time you want to use REQUERY>
 

Users who are viewing this thread

Back
Top Bottom