Splitting a database

L

Lisa

I had seen in a previous post that there was a site that could give
information on splitting a database and an update file that would create code
to deploy an updated front end when it has a different version than the main
front end. I am lost in one portion of the code, it is deleting the file
that it should be replacing. Here is my code: The main update file and the
main front end file is on is currently on a server, and I want to copy the
main front end file to the c: drive, and also make a backup copy on c:. Can
anyone see what it is that I am doing wrong?

Private Sub Form_Open(Cancel As Integer)
On Error Resume Next

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

' Load variables with correct file name-path values.
strMyDB = "\\plcicctf1\foliodev\workload\logs\Workload
04-Present\Update.mdb"
nPos = InStrRev(strMyDB, "\")
strPath = Mid(strMyDB, 1, nPos - 1)
strPath = strPath & "\workload.mdb"
strDest = Replace(strPath, "c:\workload\", "workload.mdb")
strBkup = Replace(strPath, "c:\workload\", "workload_backup.mdb")

' Stop processing here so article readers may step through code.
'Stop

' 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
 
D

Douglas J Steele

The Replace statements don't look correct.

You're creating strPath as strPath & "\workload.mdb", and then you're using
Replace to change "c:\workload\" to "workload.mdb". Assuming c:\workload\ is
in strPath, that's going to result in workload.mdb being in strPath twice!

What were you hoping that the Replace statements were going to do?
 
L

Lisa

The file that I the code is in is Update.mdb, the file that I want to copy is
\\plcicctf1\foliodev\workload\logs\Workload- 04-Present\workload.mdb and I
want to replace c:\workload\workload.mdb


Douglas J Steele said:
The Replace statements don't look correct.

You're creating strPath as strPath & "\workload.mdb", and then you're using
Replace to change "c:\workload\" to "workload.mdb". Assuming c:\workload\ is
in strPath, that's going to result in workload.mdb being in strPath twice!

What were you hoping that the Replace statements were going to do?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Lisa said:
I had seen in a previous post that there was a site that could give
information on splitting a database and an update file that would create code
to deploy an updated front end when it has a different version than the main
front end. I am lost in one portion of the code, it is deleting the file
that it should be replacing. Here is my code: The main update file and the
main front end file is on is currently on a server, and I want to copy the
main front end file to the c: drive, and also make a backup copy on c:. Can
anyone see what it is that I am doing wrong?

Private Sub Form_Open(Cancel As Integer)
On Error Resume Next

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

' Load variables with correct file name-path values.
strMyDB = "\\plcicctf1\foliodev\workload\logs\Workload
04-Present\Update.mdb"
nPos = InStrRev(strMyDB, "\")
strPath = Mid(strMyDB, 1, nPos - 1)
strPath = strPath & "\workload.mdb"
strDest = Replace(strPath, "c:\workload\", "workload.mdb")
strBkup = Replace(strPath, "c:\workload\", "workload_backup.mdb")

' Stop processing here so article readers may step through code.
'Stop

' 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
 
D

Douglas J Steele

That would seem to imply you should have

strDest = "\\plcicctf1\foliodev\workload\logs\Workload-
04-Present\\workload.mdb"

Or were you expecting that the Replace statement would relink your tables?
If so, take a look at http://www.mvps.org/access/tables/tbl0009.htm at "The
Access Web" for one way to relink tables.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Lisa said:
The file that I the code is in is Update.mdb, the file that I want to copy is
\\plcicctf1\foliodev\workload\logs\Workload- 04-Present\workload.mdb and I
want to replace c:\workload\workload.mdb


Douglas J Steele said:
The Replace statements don't look correct.

You're creating strPath as strPath & "\workload.mdb", and then you're using
Replace to change "c:\workload\" to "workload.mdb". Assuming c:\workload\ is
in strPath, that's going to result in workload.mdb being in strPath twice!

What were you hoping that the Replace statements were going to do?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Lisa said:
I had seen in a previous post that there was a site that could give
information on splitting a database and an update file that would
create
code
to deploy an updated front end when it has a different version than
the
main
front end. I am lost in one portion of the code, it is deleting the file
that it should be replacing. Here is my code: The main update file
and
the
main front end file is on is currently on a server, and I want to copy the
main front end file to the c: drive, and also make a backup copy on
c:.
Can
anyone see what it is that I am doing wrong?

Private Sub Form_Open(Cancel As Integer)
On Error Resume Next

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

' Load variables with correct file name-path values.
strMyDB = "\\plcicctf1\foliodev\workload\logs\Workload
04-Present\Update.mdb"
nPos = InStrRev(strMyDB, "\")
strPath = Mid(strMyDB, 1, nPos - 1)
strPath = strPath & "\workload.mdb"
strDest = Replace(strPath, "c:\workload\", "workload.mdb")
strBkup = Replace(strPath, "c:\workload\", "workload_backup.mdb")

' Stop processing here so article readers may step through code.
'Stop

' 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
 

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