Many thanks to the many who helped me with my last post on this subject. Well, I finally got a function working flawlessly until I password protect the database. Is there anything I can add to this code to prompt the user for a password? Or even code to embed a password? The code is :
	
	
	
		
 
		Code:
	
	
	Public Function BackupDB()
On Error GoTo BackupDB_Err
    Dim sourceFile As String, destinationFile As String
    Dim aFSO As Variant
    Dim path As String, name As String
    path = CurrentProject.path
    name = CurrentProject.name
    
    sourceFile = path & "\InvoicesBE.accdb"
    destinationFile = path & "\Backups\InvoicesBE" & _
        "_Backup" & "_" & Year(Now) & "-" & Month(Now) & _
        "-" & Day(Now) & ".accdb"
    'this removes a file created on the same day
    If Dir(destinationFile) <> "" Then
        Kill destinationFile
    End If
    
    'this creates a backup into destination path
    If Dir(destinationFile) = "" Then
        Set aFSO = CreateObject("Scripting.FileSystemObject")
        aFSO.CopyFile sourceFile, destinationFile, True
        MsgBox "A database backup has been stored under " & destinationFile
    End If
BackupDB_Exit:
    Exit Function
    
BackupDB_Err:
    ErrMsg ("BackupDB")
    Resume BackupDB_Exit
    
End Function
			
				Last edited: 
			
		
	
								
								
									
	
		
			
		
		
	
	
	
		
			
		
		
	
								
							
							 
	


 
 
		 
 
		