Full Version: Make copy of BE from FE form
UtterAccess Discussion Forums > Microsoft® Access > Access Automation
jarotoouk
Hi,

Not your usual make a backup question here.

Currently I have the following code to perform backups.

CODE
FileCopy "N:\MyDatabase_be.mdb", "N:\Backups\MyDatabase_be_Backup.mdb"


This is the basic code, but it has been expanded to allow up to 5 backups to be made and works fine.

My problem now is that my boss wants to be able to create or copy a backup on a USB stick. This wouldn't be a problem normally as I could just insert the address of the USB drive destination and "FileCopy" over to it. The problem is that the drive letter for the USB stick changes depending on what else he has plugged it/turned on at the time.

I've used some browse coding I found on UtterAccess a while back to determine the file to be copied (basBrowse by Ken Getz) I've included the code from the form, but not from the module itself.

CODE
    Dim strFilter As String, strInputFileName As String, strFil As String, strFol As String
    strFilter = ahtAddFilterItem(strFilter, "Access Databases (*.mdb)", "*.mdb")
    strFilter = ahtAddFilterItem(strFilter, "All Files (*.*)", "*.*")
        
    strInputFileName = ahtCommonFileOpenSave(Filter:=strFilter, OpenFile:=False, InitialDir:="N:\", _
     DialogTitle:=" Browse for Document...", _
     Flags:=ahtOFN_HIDEREADONLY)
                        
    If Not strInputFileName = "" Then
      Me![Source] = strInputFileName
      DoCmd.Save
    End If


this works great to locate a file, but is there any way I can alter it to allow me to either identify a folder, or actually save the "source" file to that location?

jarotoouk
OK, I've been playing a bit and discovered that I can use this function to create a filepath, even if there is no file present. This would mean I could use FileCopy to this newly generated filepath, hopefully.

Unfortunately it generates an error 29068, so I'll try to handle the code and see what happens.
HiTechCoach
I would use this:

BrowseFolder Dialog

to select the destination for the copy
jarotoouk
OK, simly put in a If err.number = 29068 then resume and it seems to have gotten around the problem.

Another question for anyone who might be familiar with the basBrowse function.

Is there any way to set "My Computer" as the default directory for the search window?
jarotoouk
HiTechCoach

Much better solution than mine thanks. Works a treat sad.gif

Again, thanks for the help, it even answers my follow-up question as it naturally show the "My Computer" dialog too
freakazeud
Hi,
check the InitialDir argument...I think there is a sample in the Function TestIt() at this site.
You can use an environ function to get the username/path to the directory.
HTH
Good luck
jarotoouk
I'll have a look at that one ta sad.gif
freakazeud
You're welcome.
Good luck!
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.