Solved Update timestamp on backup file in form code is delayed (1 Viewer)

Mike Krailo

Well-known member
Local time
Today, 00:14
Joined
Mar 28, 2020
Messages
1,043
This one's has me stumped, been working on it for hours in my main application. I have put a little sample database together to demonstrate the problem. Here is a screenshot of the form that has as it's only job to backup the currently running database to a OneDrive path (doesn't matter what the path is). When the button is pressed to do the backup, I would like that timestamp label above the button to update with the correct timestamp of the newly backed up file and turn red. The problem is the code doesn't update the label right away, instead you have to do another backup or close and open the form to get it to update.

1607829745478.png

I'm pretty sure it is a timing thing and the code gets going a little too fast. It works if you step through the code but not in Realtime. How do I tame the beast?

UPDATE: OK, I figured it out prior to posting but I'm going to post this anyway so I can refer back to it in the future. This was indeed a timing issue and I ended up using the following line of code to enable the windows sleep command to work. It just needed about 80 milliseconds of time to process the backup. It might need more if the database gets larger.

Code:
Private Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal lngMilliSeconds As Long)
 

Attachments

  • TimeStampIssue.zip
    82 KB · Views: 430

Users who are viewing this thread

Top Bottom