Solved VBA copy data from one database to another (1 Viewer)

Rania01

Member
Local time
Today, 17:49
Joined
Oct 9, 2021
Messages
59
I have 2 different databases:


1 Master Data
2 Data Backup


Please help to create a VBA command button to copy the result of the search in database called "Master Data" to Table called "BackupData" in another database called "Data Backup".


My data is ON

C:\Kirana\Data access

Thank you in advanced
 

Attachments

  • Backup Data.jpg
    Backup Data.jpg
    172.6 KB · Views: 79
Last edited:

Ranman256

Well-known member
Local time
Today, 11:49
Joined
Apr 9, 2015
Messages
4,337
dont really need vba. Link in the target tables to copy to, as external linked tables.
make append queries to add the local data to their target tables,
put all these queries in a macro.
put the macro in the button click event.
 

Rania01

Member
Local time
Today, 17:49
Joined
Oct 9, 2021
Messages
59
To deleted old record after backup i use VBA

Code:
Private Sub DeleteOlddata()

Dim strPasswd
    Dim stDocName As String
    Dim stLinkCriteria As String

    On Error GoTo Err_Command6_Click_Error
    strPasswd = InputBox("Enter Password", "Restricted Form")

    If strPasswd = "" Or strPasswd = Empty Then
        MsgBox "No Input Provided", vbInformation, "Required Data"
        Exit Sub
    End If

    If strPasswd = "12345" Then
    DoCmd.RunCommand acCmdSelectAllRecords
    DoCmd.RunCommand acCmdDelete
    Else
        MsgBox "Sorry, you do not have access to this form", vbOKOnly, _
            "Important Information"
        Exit Sub
    End If
Exit_ErrorHandler:
  Exit Sub
Err_Command6_Click_Error:
  If Err.Number = 2501 Then
    MsgBox "Delete action cancelled"
    Resume Exit_ErrorHandler
  Else
    MsgBox "Error " & Err.Number & " (" & Err.Description & _
        ") in procedure Command6_Click of VBA Document Form_T2 at Line " & Erl
    Resume Exit_ErrorHandler
  End If



End Sub

The problem is How to copy the result of the search in database called "Master Data" to Table called "BackupData" in another database called "Data Backup".
 
Last edited:

Users who are viewing this thread

Top Bottom