best way to refresh form is...

cardgunner

Registered User.
Local time
Today, 15:36
Joined
Aug 8, 2005
Messages
210
In a few of my forms I have command buttons to go to other forms. Normally they go to the other forms to add or update info to use in the form they just left. When they leave the other forms they use a command button to close it.

I have set the Activate event on the main form to refresh.

This lets them use the information they just entered or edited in the other form without hitting a refresh button in the main form.

I'm using a macro for this for no other reasons then ease for me. I could use code.

My questions are
1) Is this the best way to do it?
2) Macro vs. Code is there any performance issues or pros/cons?
3)Is the activate event the best place for this?

Thiss forums guidance and knowledge is always appreciated.
 
Last edited:
In a few of my forms I have command buttons to go to other forms. Normally they go to the other forms to add or update info to use in the form they just left. When they leave the other forms they use a command button to close it.

I have set the Activate event on the main form to refresh.

This lets them use the information they just entered or edited in the other form without hitting a refresh button in the main form.

I'm using a macro for this for no other reasons then ease for me. I could use code.

My questions are
1) Is this the best way to do it?
2) Macro vs. Code is there any performance issues or pros/cons?
3)Is the activate event the best place for this?
1) Could you not just use the Requery action on the close of one of the other forms? That would be one line of Basic for you instead of a Macro.

2) See this:
http://www.access-programmers.co.uk/forums/showthread.php?t=145532

3) Probably not. Why not the close event, or on one of the other buttons that are located outside of the "refreshed" form?
 
Thanks for your comments Trumpet.

I tried to attach the refresh cmd in the close of the other form and came up with an error. So this fresh macro on the On Activate event was the easiest and it worked.

However I found later that unless the form was filtered it would refresh and go back to first record.

So on the On Activate I used

DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70

and I'm still testing but it appears to work.

However I would LOVE get it to refresh in the close of the other form

What needs to be written in this code so it will refresh the main form?
Code:
Private Sub closefrmcmd_Click()
On Error GoTo Err_closefrmcmd_Click


    DoCmd.Close

Exit_closefrmcmd_Click:
    Exit Sub

Err_closefrmcmd_Click:
    MsgBox Err.description
    Resume Exit_closefrmcmd_Click
    
End Sub

the form this is in is the productfrm. I got there from the orderfrm. I want to close the productfrm and refresh the orderfrm.
 
the form this is in is the productfrm. I got there from the orderfrm. I want to close the productfrm and refresh the orderfrm.
Gunner,

Where is the "refreshed" data comming from? The product form? How many pieces of data are you transferring from that form to the Orders form? Do you have any other code other than the Macro code you posted? Why can't you copy values from one to the other?

I can't get a clear picture here of what you are you doing. How about a Scr. Shot of the code/forms? If not that's OK too....I know it already works for you.
 
Adam,

The Refreshed data is coming from product form.

The user can set the values of the combo boxes of the order form from the product form. There are about 4 different values set in the product table.
What happens is the info is set but when the user closes product form the information does not show in the combo boxes till he refreshes the form.

I don't want him to hit a refresh button. I want it to refresh automaticaly.

The macro code to close the product form is the only code for that form. He hits that to close the product form.

Thanks for your help.
 

Attachments

  • SShot.JPG
    SShot.JPG
    98 KB · Views: 620
Just an FYI -

Refresh is different than Requery. Most of the time you want a REQUERY, not a REFRESH. The difference is that Refresh will not include any records added or deleted by other users and will only reflect changes made to existing records.
 
Also, you should avoid the DoMenuItem coding (even though the wizards actually produce that code, it is outdated and you should use the DoCmd.RunCommand syntax instead.
 
Bob,

Thanks for the advice.

Do you mean

this
DoCmd.RunCommand acFormBar, acRecordsMenu, 5, , acMenuVer70

instead of this
DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70
??
 
Bob,

Thanks for the advice.

Do you mean

this
DoCmd.RunCommand acFormBar, acRecordsMenu, 5, , acMenuVer70

instead of this
DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70
??

No,

DoCmd.RunCommand acCmdSaveRecord
 
Thanks Bob worked like a champ.

Knowing very little about code I couldn't tell you what

DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70

does just seeing it by itself.

However

DoCmd.RunCommand acCmdSaveRecord

You do know.

Again Thanks for your help.
 

Users who are viewing this thread

Back
Top Bottom