Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / March 2005

Tip: Looking for answers? Try searching our database.

Copying the back-end db

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
James - 15 Mar 2005 00:37 GMT
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-----------
Rob Oldfield - 15 Mar 2005 00:48 GMT
Use the Right function to grab the last character of the path... if it isn't
a \, then tack one on.

> 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
[quoted text clipped - 51 lines]
> End Sub
> -----------end code-----------
Default - 15 Mar 2005 16:25 GMT
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
[quoted text clipped - 51 lines]
| End Sub
| -----------end code-----------
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.