Home > Archive > MS Access Multiuser > April 2005 > does the statement FileCopy complete before next statement is executed???









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

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

2005-04-21, 8:25 pm

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\Disc
o 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


Wayne Morgan

2005-04-21, 8:25 pm

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" <tlsilveus@hotmail.com> wrote in message
news:%232asQBrRFHA.1476@TK2MSFTNGP09.phx.gbl...
> 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\Disc
o 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
>



tw

2005-04-22, 8:24 pm

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" < comprev_gothroughthe
newsgroup@hotmail.com> wrote in message
news:e8avFGtRFHA.3444@tk2msftngp13.phx.gbl...
> 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" <tlsilveus@hotmail.com> wrote in message
> news:%232asQBrRFHA.1476@TK2MSFTNGP09.phx.gbl...
>
>



Brendan Reynolds

2005-04-22, 8:24 pm

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

--
Brendan Reynolds (MVP)

"tw" <tlsilveus@hotmail.com> wrote in message
news:%23N3wh32RFHA.3972@TK2MSFTNGP14.phx.gbl...
> 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" < comprev_gothroughthe
newsgroup@hotmail.com> wrote in
> message news:e8avFGtRFHA.3444@tk2msftngp13.phx.gbl...
>
>



tw

2005-04-22, 8:24 pm

Thanks, I got it with DoEvents

"tw" <tlsilveus@hotmail.com> wrote in message
news:%232asQBrRFHA.1476@TK2MSFTNGP09.phx.gbl...
> 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\Disc
o 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
>



Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com