does the statement FileCopy complete before next statement is executed???

T

tw

Paths are hardcoded for testing purposes only...

This code is called only if an update is needed. I have the following code
in the splash screen of an updater program. The code works perfectly on my
machine, XP. I tested it on a win98 machine and it did not work, the file
never copied, however when I steped through the code on the win98 machine,
it worked fine. I'm thinking maybe I slowed it down by stepping through it
causing it to work. But that doesn't seem right, especially because when I
didn't step through the code, the file never completed copying (unless the
quit statement stopped the copy process). So I don't know what might be
wrong. The paths are all there and identical to what is stated below.

Option Compare Database
Option Explicit
Dim strDest As String
Dim strMyDB As String
Dim strVer As String
Private Sub Form_Open(Cancel As Integer)
On Error Resume Next
Dim strPath As String
Dim strBkup As String

' Update status form to identify version being copied.
strVer = DLookup("[VersionNumber]", "tblVersionServer")
Me.lblServerVersion.Caption = "Installing version number ... " & strVer
Me.Repaint

' Load variables with correct file name-path values.
strMyDB = CurrentDb.Name
strPath = "C:\Disco\"
strDest = "C:\Disco\Disco 2 Front End.mdb"
strBkup = "C:\Disco\BackUp\Disco 2 Front End.mdb"

' Create a backup (replacing existing backup if necessary) and
' remove the target file.
If Dir(strBkup) <> "" Then Kill strBkup
FileCopy strDest, strBkup
If Dir(strDest) <> "" Then Kill strDest
End Sub
Private Sub Form_Timer()
On Error Resume Next
Dim strSource As String
Dim strMsg As String
Dim strOpenClient As String
Dim strPath As String
Dim strBkup As String
Dim strWRKGRP As String

Const q As String = """"

strPath = Left(strMyDB, InStrRev(strMyDB, "\"))
strWRKGRP = "\\loving_care\Disco Data\DiscoSecure.mdw"

' We make the assumption that the new client is in the
' same folder as this utility.
strSource = strPath & "Disco 2 Front End.mdb"
FileCopy strSource, strDest

'add the workgroup switch before calling
strDest = q & strDest & q & " /WRKGRP " & q & strWRKGRP & q

' Now that the new client file has been copied, it may
' be opened. Use the SHELL command to accomplish this.
strOpenClient = "MSAccess.exe " & strDest
Shell strOpenClient, vbNormalFocus
' Exit from this application.
DoCmd.Quit
End Sub
 
W

Wayne Morgan

You are correct about it sounding like a timing problem; however, I think it
may be something else causing it. You are making the backup and deleting the
original in the form's Open event. You are copying the new version to the
original's location in the form's Timer event. What is the Timer Interval?
Could you be copying the new version over the old one before the Open code
deletes the old one or is it possible that the timer isn't running? Try
setting the Timer Interval to zero and in the Open event, after you've
deleted the strDest file, set the Timer Interval to the desired value.

Example:
Me.TimerInterval = 10000 '10 seconds

--
Wayne Morgan
MS Access MVP


tw said:
Paths are hardcoded for testing purposes only...

This code is called only if an update is needed. I have the following
code in the splash screen of an updater program. The code works perfectly
on my machine, XP. I tested it on a win98 machine and it did not work,
the file never copied, however when I steped through the code on the win98
machine, it worked fine. I'm thinking maybe I slowed it down by stepping
through it causing it to work. But that doesn't seem right, especially
because when I didn't step through the code, the file never completed
copying (unless the quit statement stopped the copy process). So I don't
know what might be wrong. The paths are all there and identical to what
is stated below.

Option Compare Database
Option Explicit
Dim strDest As String
Dim strMyDB As String
Dim strVer As String
Private Sub Form_Open(Cancel As Integer)
On Error Resume Next
Dim strPath As String
Dim strBkup As String

' Update status form to identify version being copied.
strVer = DLookup("[VersionNumber]", "tblVersionServer")
Me.lblServerVersion.Caption = "Installing version number ... " & strVer
Me.Repaint

' Load variables with correct file name-path values.
strMyDB = CurrentDb.Name
strPath = "C:\Disco\"
strDest = "C:\Disco\Disco 2 Front End.mdb"
strBkup = "C:\Disco\BackUp\Disco 2 Front End.mdb"

' Create a backup (replacing existing backup if necessary) and
' remove the target file.
If Dir(strBkup) <> "" Then Kill strBkup
FileCopy strDest, strBkup
If Dir(strDest) <> "" Then Kill strDest
End Sub
Private Sub Form_Timer()
On Error Resume Next
Dim strSource As String
Dim strMsg As String
Dim strOpenClient As String
Dim strPath As String
Dim strBkup As String
Dim strWRKGRP As String

Const q As String = """"

strPath = Left(strMyDB, InStrRev(strMyDB, "\"))
strWRKGRP = "\\loving_care\Disco Data\DiscoSecure.mdw"

' We make the assumption that the new client is in the
' same folder as this utility.
strSource = strPath & "Disco 2 Front End.mdb"
FileCopy strSource, strDest

'add the workgroup switch before calling
strDest = q & strDest & q & " /WRKGRP " & q & strWRKGRP & q

' Now that the new client file has been copied, it may
' be opened. Use the SHELL command to accomplish this.
strOpenClient = "MSAccess.exe " & strDest
Shell strOpenClient, vbNormalFocus
' Exit from this application.
DoCmd.Quit
End Sub
 
T

tw

The timer event does run, becuase when I put a break I can step through it
and it works. The timerinterval is set to 1000 or 1 second. You may be
right. It may not be long enough to delete the file. I will increase that
and see if it works.

Wayne Morgan said:
You are correct about it sounding like a timing problem; however, I think
it may be something else causing it. You are making the backup and
deleting the original in the form's Open event. You are copying the new
version to the original's location in the form's Timer event. What is the
Timer Interval? Could you be copying the new version over the old one
before the Open code deletes the old one or is it possible that the timer
isn't running? Try setting the Timer Interval to zero and in the Open
event, after you've deleted the strDest file, set the Timer Interval to
the desired value.

Example:
Me.TimerInterval = 10000 '10 seconds

--
Wayne Morgan
MS Access MVP


tw said:
Paths are hardcoded for testing purposes only...

This code is called only if an update is needed. I have the following
code in the splash screen of an updater program. The code works
perfectly on my machine, XP. I tested it on a win98 machine and it did
not work, the file never copied, however when I steped through the code
on the win98 machine, it worked fine. I'm thinking maybe I slowed it
down by stepping through it causing it to work. But that doesn't seem
right, especially because when I didn't step through the code, the file
never completed copying (unless the quit statement stopped the copy
process). So I don't know what might be wrong. The paths are all there
and identical to what is stated below.

Option Compare Database
Option Explicit
Dim strDest As String
Dim strMyDB As String
Dim strVer As String
Private Sub Form_Open(Cancel As Integer)
On Error Resume Next
Dim strPath As String
Dim strBkup As String

' Update status form to identify version being copied.
strVer = DLookup("[VersionNumber]", "tblVersionServer")
Me.lblServerVersion.Caption = "Installing version number ... " &
strVer
Me.Repaint

' Load variables with correct file name-path values.
strMyDB = CurrentDb.Name
strPath = "C:\Disco\"
strDest = "C:\Disco\Disco 2 Front End.mdb"
strBkup = "C:\Disco\BackUp\Disco 2 Front End.mdb"

' Create a backup (replacing existing backup if necessary) and
' remove the target file.
If Dir(strBkup) <> "" Then Kill strBkup
FileCopy strDest, strBkup
If Dir(strDest) <> "" Then Kill strDest
End Sub
Private Sub Form_Timer()
On Error Resume Next
Dim strSource As String
Dim strMsg As String
Dim strOpenClient As String
Dim strPath As String
Dim strBkup As String
Dim strWRKGRP As String

Const q As String = """"

strPath = Left(strMyDB, InStrRev(strMyDB, "\"))
strWRKGRP = "\\loving_care\Disco Data\DiscoSecure.mdw"

' We make the assumption that the new client is in the
' same folder as this utility.
strSource = strPath & "Disco 2 Front End.mdb"
FileCopy strSource, strDest

'add the workgroup switch before calling
strDest = q & strDest & q & " /WRKGRP " & q & strWRKGRP & q

' Now that the new client file has been copied, it may
' be opened. Use the SHELL command to accomplish this.
strOpenClient = "MSAccess.exe " & strDest
Shell strOpenClient, vbNormalFocus
' Exit from this application.
DoCmd.Quit
End Sub
 
B

Brendan Reynolds

It may help to put in a DoEvents after the deletion of the file.

--
Brendan Reynolds (MVP)

tw said:
The timer event does run, becuase when I put a break I can step through it
and it works. The timerinterval is set to 1000 or 1 second. You may be
right. It may not be long enough to delete the file. I will increase
that and see if it works.

Wayne Morgan said:
You are correct about it sounding like a timing problem; however, I think
it may be something else causing it. You are making the backup and
deleting the original in the form's Open event. You are copying the new
version to the original's location in the form's Timer event. What is the
Timer Interval? Could you be copying the new version over the old one
before the Open code deletes the old one or is it possible that the timer
isn't running? Try setting the Timer Interval to zero and in the Open
event, after you've deleted the strDest file, set the Timer Interval to
the desired value.

Example:
Me.TimerInterval = 10000 '10 seconds

--
Wayne Morgan
MS Access MVP


tw said:
Paths are hardcoded for testing purposes only...

This code is called only if an update is needed. I have the following
code in the splash screen of an updater program. The code works
perfectly on my machine, XP. I tested it on a win98 machine and it did
not work, the file never copied, however when I steped through the code
on the win98 machine, it worked fine. I'm thinking maybe I slowed it
down by stepping through it causing it to work. But that doesn't seem
right, especially because when I didn't step through the code, the file
never completed copying (unless the quit statement stopped the copy
process). So I don't know what might be wrong. The paths are all there
and identical to what is stated below.

Option Compare Database
Option Explicit
Dim strDest As String
Dim strMyDB As String
Dim strVer As String
Private Sub Form_Open(Cancel As Integer)
On Error Resume Next
Dim strPath As String
Dim strBkup As String

' Update status form to identify version being copied.
strVer = DLookup("[VersionNumber]", "tblVersionServer")
Me.lblServerVersion.Caption = "Installing version number ... " &
strVer
Me.Repaint

' Load variables with correct file name-path values.
strMyDB = CurrentDb.Name
strPath = "C:\Disco\"
strDest = "C:\Disco\Disco 2 Front End.mdb"
strBkup = "C:\Disco\BackUp\Disco 2 Front End.mdb"

' Create a backup (replacing existing backup if necessary) and
' remove the target file.
If Dir(strBkup) <> "" Then Kill strBkup
FileCopy strDest, strBkup
If Dir(strDest) <> "" Then Kill strDest
End Sub
Private Sub Form_Timer()
On Error Resume Next
Dim strSource As String
Dim strMsg As String
Dim strOpenClient As String
Dim strPath As String
Dim strBkup As String
Dim strWRKGRP As String

Const q As String = """"

strPath = Left(strMyDB, InStrRev(strMyDB, "\"))
strWRKGRP = "\\loving_care\Disco Data\DiscoSecure.mdw"

' We make the assumption that the new client is in the
' same folder as this utility.
strSource = strPath & "Disco 2 Front End.mdb"
FileCopy strSource, strDest

'add the workgroup switch before calling
strDest = q & strDest & q & " /WRKGRP " & q & strWRKGRP & q

' Now that the new client file has been copied, it may
' be opened. Use the SHELL command to accomplish this.
strOpenClient = "MSAccess.exe " & strDest
Shell strOpenClient, vbNormalFocus
' Exit from this application.
DoCmd.Quit
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top