MsgBox Dialogue and Windows popup dialog (1 Viewer)

sxschech

Registered User.
Local time
Today, 13:22
Joined
Mar 2, 2010
Messages
792
In running a process, I put up a message box with vbokonly to let user know it was completed and to be sure rest of the code did not continue running until other process completed and they then clicked ok. However, today, I noticed that the popup box was briefly covered by the windows popup box which was copying a file. This popup has a Cancel button positioned in same spot where the ok button is on my popup. Since usually things go smoothly, box shows up, click ok and go on to the next thing. Perhaps because the file was bigger, it took longer to copy and here is what happened, my box pops up, I go to click ok, but wait, it says cancel instead, oops, already clicked it as usually the copy happens so quickly don't see the windows popup, (meaning that I clicked the button to cancel copying the file rather than clicking Ok that process was complete). Any thoughts how I can have my popup display only after the windows process finishes, or how I can have the popup display in such a way that the windows popup isn't aligned over mine?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 13:22
Joined
Oct 29, 2018
Messages
21,454
Hi. If you're using a message box to let the user know a file copy process has completed, then maybe you could check if the file exists in the new location first before popping the message. For example, you could try using the Dir() function in a loop and keep looking for a period of time before giving up or showing the message.
 

June7

AWF VIP
Local time
Today, 12:22
Joined
Mar 9, 2014
Messages
5,466
Maybe Sleep and DoEvents would be useful? https://www.fmsinc.com/MicrosoftAccess/modules/examples/AvoidDoEvents.asp

Here is code I used, maybe should use Sleep component but this has always worked just fine:
Code:
        'allow enough time for file to completely copy before opening
        Dim Start As Double
        Start = Timer
        While Timer < Start + 3
            DoEvents
        Wend
 

sxschech

Registered User.
Local time
Today, 13:22
Joined
Mar 2, 2010
Messages
792
Thanks to you both for suggestions. At first tried using theDBguy's method. As the file I'm copying is going into a zip, I had to find modify code in order to tell me if the file is in the zip. I tested the function on its own and seemed to work,
then added a loop into the code between the function that adds the file to the zip and the message box saying that the file was added. something like this:

Code:
Do Until IsInZip(zipfilename, covsheet) = True
    Loop

Not sure if in my test I got the file wrong or there was another issue, but it ended up in a never ending loop. Perhaps I need a method to check for the file but have it give up after a certain number of loops or does the loop need to be written differently.

In the meantime, I'll try out June7's approach.
 

Users who are viewing this thread

Top Bottom