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

Simultaneous Code Execution?

100+
P: 107
I have a form (Form A) that has a print command button - the resulting report takes about 3 to 5 seconds to open.

To notify the user, I developed a form (Form B) and code to animate a "Your Report is Being Generated" display (there are 4 dots that move across the form.) This is the only purpose of this Form B - it is closed when the calling procedure (located on Form A) completes.

The code on Form B works perfectly when I open the form on it's own (all animation is perfect) however, when the form is opened from Form A, everything works fine however, Form B is not animated (it is just a static image.)

Simplified code example is below:
Expand|Select|Wrap|Line Numbers
  1.     ‘Hides Form A (Calling Form)
  2.     Me.Visible = False 
  3.  
  4.    ‘Opens Form B (“Your Report is Being Generated” Form with Animation)
  5.     DoCmd.OpenForm "FormB"
  6.  
  7.     DoEvents
  8.  
  9.     DoCmd.OpenReport "rptSaleOrderPrintOut_Portrait", acViewReport
  10.              With Reports!rptSaleOrderPrintOut_Portrait.Report
  11.                 .Filter = Nz(Me.sfrmSaleOrderSearch.Form.Filter, "*")
  12.                 .FilterOn = IIf(Nz(Me.sfrmSaleOrderSearch.Form.Filter, "") = "", False, True)
  13.              End With
  14.  
  15.    DoCmd.Close acForm, "FormB"
I excluded the code Form B (all located in the Form Time event) as it seems to work well but I can share this if needed as well.

Thanks in advance for any assistance.

Gunner

Attached Images
File Type: jpg Form A (Logo Removed).jpg (61.0 KB, 267 views)
File Type: png Form B (Logo Removed).png (8.4 KB, 200 views)
Jan 1 '18 #1
Share this Question
Share on Google+
4 Replies


100+
P: 107
I also noted that if I do not close the Form B, the animation begins working on its own as soon as the report opens. Not sure if that helps...
Jan 2 '18 #2

twinnyfo
Expert Mod 2.5K+
P: 3,210
dgunner71,

Unfortunately, as far as I know, MS Access can only do "one thing at a time". As soon at you open Form B, although you use the command DoEvents to initiate the actions, as soon as you execute code to open the Report, all activity on Form B will pause until the processes complete for that Report. This is also why once the Report is open, Form B begins to function "normally".

This is not a "solution" to your question, but rather an explanation about why you are getting those particular results.

Hope this hepps!
Jan 2 '18 #3

NeoPa
Expert Mod 15k+
P: 31,419
TwinnyFo's spot on. I can only wonder why you'd imagine the code could control Form B when the report is being opened. There is no possibility of executing DoEvents from within the processing of the data.

There is some small scope to be had from events which fire during the formatting of each section so you could try a DoEvents in there. It's likely to be a small fraction of the overall time though. Usually, when a report is being prepared and the initial grabbing of the data takes more than a second or two, you'll see a progress indicator in the status bar anyway. Until that's completed I'd not expect your form to have any activity. In most cases the time to format and show the data once grabbed is minimal anyway. A second or so even for a long report.

As I say, you may like to try that but I don't expect it to give you much joy. VBA is fundamentally a single process, allowing only one thing to run at any one time and when data is being grabbed then that process is busy.
Jan 3 '18 #4

100+
P: 107
Thanks all - this answers my question.

Happy New Year.

Gunner
Jan 4 '18 #5

Post your reply

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