By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,948 Members | 838 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,948 IT Pros & Developers. It's quick & easy.

Synchronize DoCmd processing with VBA execution

P: 11
I understand Access lets the VBA statements following a DoCmd statement execute before a DoCmd has completed. I have a situation where I use a DoCmd.DoMenuItem (copied from the UNDO button VBA) to cancel an ADD operation (new empty record already created for the bound form) and then make changes to the RecordSource for my form. So, I want to wait for the DoCmd.DoMenuItem to complete. How do I do it?

Being somewhat of a newbie, I only know how to synchronize with a pop-up form, but it's not an option here. Too intrusive.
Sep 9 '08 #1
Share this Question
Share on Google+
3 Replies


missinglinq
Expert 2.5K+
P: 3,532
Try placing the line

DoEvents

between the two commands.

Linq ;0)>
Sep 10 '08 #2

P: 11
Try placing the line

DoEvents

between the two commands.

Linq ;0)>
I looked up DoEvents, did what you suggested and it worked. Apparently DoEvent uses Windows services. Thanks!
Sep 10 '08 #3

missinglinq
Expert 2.5K+
P: 3,532
That's correct! DoEvents basically relinquishes control to Windows until the current event is concluded then returns control to Access to carryout the next task. It's a good bet when timing appears to be the problem.

Glad we could help!

Linq ;0)>
Sep 10 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.