Copying the back-end db

G

Guest

I have a button that copies the back-end to a new file and renames it. At
first it would not work (unless saveing to root drive) because I didn't have
the "\" before the file name. Now it will save to a folder only but not the
root drive. How do let the user save the file anywhere?

Breakdown of code below:
I have three txtBoxes (txtfolderPath, txtDest, & txtsource)...txtFolderPath
is selected using a function GetOpenFileName by Ken Getz. It grabs the drive
and folder corretl, but it's my code that is screwing things up (the code
below).

---------------start code---------
Option Compare Database
Option Explicit

Dim DateNow As String
Dim DestinationFile As String


Private Sub cmdBackup_Click()
On Error GoTo Err_cmdBackup_Click

DestinationFile = Me.txtFolderPath & "\PLOG2005BE" & Format(DateNow,
"mmddyy") & ".bku"
Me.txtDest = DestinationFile
FileCopy Me.txtSource, Me.txtDest
MsgBox "Backup Successful.", , "PackageLog 2005"
Exit_cmdBackup_Click:
Exit Sub

Err_cmdBackup_Click:
MsgBox Err.Description
Resume Exit_cmdBackup_Click

End Sub
Private Sub Form_Load()
On Error GoTo Err_Form_Load
Dim DataBE As String

DateNow = Now()
DataBE = CurrentDBDir & "PLOGBE.mdb"
DestinationFile = Me.txtFolderPath & "PLOG2005BE" & Format(DateNow,
"mmddyy") & ".bku"

Me.txtSource = DataBE
Me.txtDest = DestinationFile

Exit_Form_Load:
Exit Sub

Err_Form_Load:
MsgBox Err.Description
Resume Exit_Form_Load

End Sub
-----------end code-----------
 
R

Rob Oldfield

Use the Right function to grab the last character of the path... if it isn't
a \, then tack one on.
 
D

Default

With the code your using when you select the root as the folder you end up
with two \\ (slashes) and that makes the filename a UNC or network path.

You should, instead of adding the slash to the front of the filename, add it
to the end of the path as the previous poster suggested.

Brian

| I have a button that copies the back-end to a new file and renames it. At
| first it would not work (unless saveing to root drive) because I didn't
have
| the "\" before the file name. Now it will save to a folder only but not
the
| root drive. How do let the user save the file anywhere?
|
| Breakdown of code below:
| I have three txtBoxes (txtfolderPath, txtDest, &
txtsource)...txtFolderPath
| is selected using a function GetOpenFileName by Ken Getz. It grabs the
drive
| and folder corretl, but it's my code that is screwing things up (the code
| below).
|
| ---------------start code---------
| Option Compare Database
| Option Explicit
|
| Dim DateNow As String
| Dim DestinationFile As String
|
|
| Private Sub cmdBackup_Click()
| On Error GoTo Err_cmdBackup_Click
|
| DestinationFile = Me.txtFolderPath & "\PLOG2005BE" & Format(DateNow,
| "mmddyy") & ".bku"
| Me.txtDest = DestinationFile
| FileCopy Me.txtSource, Me.txtDest
| MsgBox "Backup Successful.", , "PackageLog 2005"
| Exit_cmdBackup_Click:
| Exit Sub
|
| Err_cmdBackup_Click:
| MsgBox Err.Description
| Resume Exit_cmdBackup_Click
|
| End Sub
| Private Sub Form_Load()
| On Error GoTo Err_Form_Load
| Dim DataBE As String
|
| DateNow = Now()
| DataBE = CurrentDBDir & "PLOGBE.mdb"
| DestinationFile = Me.txtFolderPath & "PLOG2005BE" & Format(DateNow,
| "mmddyy") & ".bku"
|
| Me.txtSource = DataBE
| Me.txtDest = DestinationFile
|
| Exit_Form_Load:
| Exit Sub
|
| Err_Form_Load:
| MsgBox Err.Description
| Resume Exit_Form_Load
|
| End Sub
| -----------end code-----------
 

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

Similar Threads


Top