Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8307155
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:28:17+00:00 2026-06-08T18:28:17+00:00

I created an Access database which I want to distribute to a small group.

  • 0

I created an Access database which I want to distribute to a small group. While I can always export the tables in excel and merge them/append data there, is there a way to sync the databases, maybe by using VBA?

To expound further, in one form in the database application, a sync button may exist, and onclick, a dialog box may open to look for the accdb to sync with. What ensues is that the VBA will “sync” the table (which of course is of the same structure) in question between the two accdbs.

Is this possible? Insights will be good. Thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T18:28:18+00:00Added an answer on June 8, 2026 at 6:28 pm

    Yes, it is perfectly possible. Here are some notes on comparing two DBs and logging changes.

    The procedure requires the following at the top of the module:

    Dim strFileNew As String 
    Dim strFileOld As String 
    Dim strLog As String
    Dim dbOld As Database
    

    The variables might contain:

    strLog = "log.txt"
    strFileNew = "z:\docs\dbNew.mdb"
    strFileOld = "z:\docs\dbOld.mdb"
    Set dbOld = OpenDatabase(strFileOld)
    

    Then the comparison:

    Sub LogCompareDB(db As Database)
    ''References : Windows Script Host Object Model
    ''           This is set by default for a number of versions
    ''           : Microsoft DAO x.x Object Library
    ''           For 2010, the DAO library is called 
    ''           :Microsoft Office 12.0 Access Database Engine Object Library
    
    Dim tdf As TableDef
    Dim rs0 As DAO.Recordset
    Dim rs1 As DAO.Recordset
    Dim fld As DAO.Field
    Dim idx As Index
    Dim idxPrimary  As Index
    Dim strIndexList As String
    Dim strIndex As String
    Dim strID As String
    Dim strSQL As String
    Dim strChanged As String
    Dim blnNew As Boolean
    Dim fs As New FileSystemObject
    Dim ts As TextStream
    
        Set ts = fs.CreateTextFile(strLog, True)
    
        ''For each table in the old database
        ''(It would probably be a good idea to check the
        ''new database for added tables)
        For Each tdf In db.TableDefs
            '' Skip system tables
            If Left(tdf.Name, 4) <> "MSys" Then
                strIndex = vbNullString
                Set idxPrimary = Nothing
                strIndexList = vbNullString
    
                ''Get the primary index and index fields
                For Each idx In tdf.Indexes
                    If idx.Primary = True Then
                        Set idxPrimary = idx
                        For Each fld In idx.Fields
                            strIndex = strIndex & " AND t0.[" & fld.Name _
                                & "] = t1.[" & fld.Name & "]"
                            strIndexList = strIndexList & "," & fld.Name
                        Next
                        strIndex = Mid(strIndex, 5)
                    End If
                Next
    
                ''There is no basis for comparison if there is no index.
                ''A unique index would also be a possibility, but hey, let's
                ''not go over the top :)
                If strIndex > vbNullString Then
    
                    ''Select all records from the table for both databases
                    strSQL = "SELECT * FROM [;DATABASE=" & strFileNew & "].[" _
                        & tdf.Name & "] As t0 LEFT JOIN [" _
                        & tdf.Name & "] As t1 ON " & strIndex
    
                    Set rs0 = db.OpenRecordset(strSQL)
    
                    ''A convenient list of fields from the old database
                    ''It would probably be a good idea to check the
                    ''new database for added fields.
    
                    strSQL = "SELECT * FROM [;DATABASE=" & strFileOld & "].[" _
                        & tdf.Name & "] As t0 WHERE 1=2"
    
                    Set rs1 = db.OpenRecordset(strSQL)
    
                    Do While Not rs0.EOF
                        strID = vbNullString
                        blnNew = False
    
                        ''If the index fields are null, then it is a new record
                        For Each fld In idxPrimary.Fields
                            strID = strID & fld.Name & ": " & rs0("[t0." & fld.Name & "]") & vbCrLf
    
                            If IsNull(rs0("[t1." & fld.Name & "]")) Then
                                blnNew = True
                            End If
                        Next
    
                        If blnNew Then
                            ''Write to log
                            ts.WriteLine "NEW RECORD " & strID & vbCrLf
                        Else
                            ''Not a new record, so is it a changed record?
                            strChanged = vbNullString
    
                            For Each fld In rs1.Fields
                                ''No need to check index fields, because they are equal
                                If InStr(strIndexList, fld.Name) = 0 Then
    
                                    ''Add null string for purposes of comparison                                 ''trailing
                                    If "" & rs0("[t0." & fld.Name & "]") <> "" & rs0("[t1." & fld.Name & "]") Then
                                        strChanged = strChanged & vbCrLf _
                                            & fld.Name & "  Is: " & Trim(rs0("[t0." & fld.Name & "]")) _
                                            & "  Was: " & Trim(rs0("[t1." & fld.Name & "]"))
                                    End If
                                End If
                            Next
    
                            If strChanged <> vbNullString Then
                                ''Write to log
                                ts.WriteLine "CHANGED RECORD " & strID
                                ts.WriteLine strChanged & vbCrLf
                            End If
                        End If
    
                        rs0.MoveNext
                    Loop
                Else
                    ts.WriteLine "NO PRIMARY INDEX " & tdf.Name & vbCrLf
                End If
            End If
        Next
    
       ts.Close
       FollowHyperlink strLog
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created an application which reads ms access database file (test.accdb). When i
I am using LINQ to access my database, and thereby gets a LINQ-created object
I created a C# application and integrated an Access DB (with 3 populated tables).
So I've created a form in Access, which has a combo box and a
I have a Microsoft Access 2010 database(*). Now, using Visual Studio 2010, I want
I have created a class file database.php which handles all the sql queries and
Possible Duplicate: Access database of another app I made an app which is a
i have to create reports with certain data from an access database. i want
i want to add the records into the MS access database from the form
I have a database in which the tables do not have primary/foreign keys. This

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.