Hi,

My database in Access contains record since 2005 and it is not required for frequent use unless the Audit ask for.
So I would like to take the backup of the data through VB6 by writing code instead of going to Access and copying in CD
So will any one write me simple code for this.
my table name is aa and database file is bb under path C:\bill

(kehar)

This is what I did to backup my DB whenever I had to - problem is I'm not sure how to find the file to restore it.

Public Sub backupDB()

        Dim backupName As String
        Dim DBName As String

        DBName = DBPath + "bb.mdb"

        backupName = Now.Hour & "-" & Now.Minute & "_" & Now.Month & "-" & Now.Year & "_DBbackup.mdb"

        Dim backupDBPath As String = DBPath + "backup/" + backupName

        FileCopy(portfolioDBName, backupDBPath)

        MsgBox("Backup Successful")

    End Sub

Why you want all the coding instead of taking back up of the mdb file itself. What is the problem in that ?

This is what I did to backup my DB whenever I had to - problem is I'm not sure how to find the file to restore it.

Typically, Microsoft recommends storing that type of information in the registry. In Windows 3.1 days, they stored it in the program's INI file.

For the registry use the GetSetting and SaveSetting functions

SaveSetting App.Name, App.Name & "Settings", "BackUpPath", backupDBPath

' Retrieve it
GetSetting App.Name, App.Name & "Settings", "BackUpPath",  App.Name ' Last Value is a default value, if it's not present

If you're adventurous and curious and have a desire for the deeper knowledge in the world of VB programming, then investigate the GetPrivateProfileString and WritePrivateProfileString functions.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.