Results 1 to 9 of 9
  1. #1
    twgonder is offline Expert
    Windows 10 Access 2021
    Join Date
    Jun 2022
    Location
    Colombia
    Posts
    714

    Change save in location for save as Back Up Database

    Before a few days ago, if I backed up a database, it would save to the same directory of the .accdb that I was working in.
    (File > Save As > Back Up Database > Save As)
    Now it tries to go to the Documents folder.
    I've searched and looked, but I can't find where this is set or why it changed.
    It's not the same as the Options > General > Default database folder, which isn't Documents.


    Any ideas?

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    i use this code to backup my db to the target folder in :Const kTargetDir =

    make a button to run: BackupDB



    Code:
    Public Function BackupDb()
    Dim vDir, f, vExt, vTargFile, vSrcDB
    Dim vTargDir, vSuffx
    
    
    Const kTargetDir = "\\server\BackupFolder\"
    
    
       vSrcDB = CurrentDb.Name
       If vSrcDB <> "" Then
            getDirName vDB, vDir, f
            vExt = Mid(f, InStrRev(f, "."))
            
            vTargDir = kTargetDir
        
            vSuffx = "_Backup" & format(Now,"yymmdd-hhnn") & vExt
            
             vTargFile = vTargDir & f & vSuffx
             Copy1File vSrcDB, vTargFile
      End If
         
         'FRONT END APP
       MsgBox "Done", vbInformation, "Backup"
    End Function
    
    
    
    
    Public Function Copy1File(ByVal pvSrc, ByVal pvTarg) As Boolean
    Dim fso
    On Error GoTo errMake
    
    
    Set fso = CreateObject("Scripting.FileSystemObject")    '(reference: ms Scripting Runtime)
    fso.CopyFile pvSrc, pvTarg
    Copy1File = True
    Set fso = Nothing
    Exit Function
    
    
    errMake:
    'MsgBox Err.Description & vbCrLf & pvSrc, , "Copy1File(): " & Err
    Set fso = Nothing
    End Function
    
    
    
    
    
    
    
    Public Sub getDirName(ByVal psFilePath, ByRef prvDir, Optional ByRef prvFile)
        'psFilePath: full file path given
        'prvDir : directory name output
        'prvFile: filename only output
    Dim i As Integer, sDir As String
    
    
    i = InStrRev(psFilePath, "\")          'not available in '97
    If i > 0 Then
      prvDir = Left(psFilePath, i)
      prvFile = Mid(psFilePath, i + 1)
      ''If Asc(Mid(prvFile, Len(prvFile), 1)) = 0 Then RemoveLastChr prvFile
    End If
    End Sub

  3. #3
    twgonder is offline Expert
    Windows 10 Access 2021
    Join Date
    Jun 2022
    Location
    Colombia
    Posts
    714
    I should have mentioned that I am now on Access 2021 Version 2407 Build 16.0.17830.20166 64-bit

  4. #4
    twgonder is offline Expert
    Windows 10 Access 2021
    Join Date
    Jun 2022
    Location
    Colombia
    Posts
    714
    Just as quickly as the problem appeared, it just disappeared. No changes to Access or Windows settings were made.
    Version 2411 Build 18227.20162

  5. #5
    twgonder is offline Expert
    Windows 10 Access 2021
    Join Date
    Jun 2022
    Location
    Colombia
    Posts
    714
    @ ranman256 Post #2 Doesn't compile

  6. #6
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,566
    Quote Originally Posted by twgonder View Post
    @ ranman256 Post #2 Doesn't compile
    And you cannot say why?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  7. #7
    twgonder is offline Expert
    Windows 10 Access 2021
    Join Date
    Jun 2022
    Location
    Colombia
    Posts
    714
    @Welshgasman post #6 Because there is a bug in the code? I wish I had time to debug code that a person says works for them, but not for which versions of Access. I'm using 2021, and it doesn't compile. It's easy to copy the code and see the error message for yourself, if you have a version of Access that has a problem with the code similar to my version.

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 11 Access 2021
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    I had to deal with "variable not defined" on vDB, otherwise compiles. (Where is vDB declared and populated?)

    Do you have reference to Microsoft Scripting Runtime Library? This is needed for FSO.

    This is why you should provide error message you get, because I don't get same.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #9
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,566
    Quote Originally Posted by June7 View Post
    I had to deal with "variable not defined" on vDB, otherwise compiles. (Where is vDB declared and populated?)

    Do you have reference to Microsoft Scripting Runtime Library? This is needed for FSO.

    This is why you should provide error message you get, because I don't get same.
    I believe the vDB is meant to be vSrcDB ?

    getDirName vSrcDB, vDir, f

    With a slight change for backup path, I am now using that for my Diabetes DB. So thank you @ranman256
    Last edited by Welshgasman; 12-28-2024 at 08:46 AM.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 15
    Last Post: 03-07-2023, 01:43 PM
  2. Replies: 2
    Last Post: 10-06-2020, 02:26 PM
  3. Selecting Save to location
    By Thompyt in forum Programming
    Replies: 2
    Last Post: 03-15-2019, 11:30 AM
  4. Replies: 10
    Last Post: 09-03-2017, 06:08 AM
  5. Replies: 4
    Last Post: 08-26-2015, 02:30 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums