problem with backup recovery process

GR_mahdi

New member
Local time
Today, 23:58
Joined
Dec 19, 2012
Messages
4
Hi to all
I want to make an recovery process for my Program as this way:

have an table that I enter my tables name that want to import from another db and delete from my db.
for each name check in another db if exists then check in my db if exist delete it and import that from that db to my db.
notice that i can select that database and can get that address.

thank s for your help
 
You can execute a query from one location to bring data into another DB
<define sql code > INTO Regulatory_GIS IN
CurrentDb.Execute mySQL

Look at the INTO statement

Code:
Private Sub cmd_Update_GIS_DB_Click()
      Dim mySQL As String
      Dim DBPath As String
      Dim Result
      Dim TblName As String
      Dim RecordCount As Long
      Dim RecordCountMessage
10    On Error GoTo PROC_EXIT
20    DoCmd.Hourglass True
30       DBPath = "X:\Tax\Audits\Regulatory_GIS.accdb"     
40       TblName = "Regulatory_GIS"
          ' Only change path here <<<<<<<<<<<<<<<<<<<  Database path and Table Name   >>>>>>>>>>>>>>>>>>>>>>>>>
        mySQL = "SELECT View_GIS_Union.ObjectID, View_GIS_Union.St, View_GIS_Union.Well_Name, View_GIS_Union.SHLBHL, View_GIS_Union.ReqFin, " & _
"CDbl([View_GIS_Union].[Latitude_GIS]) AS [LatitudeGIS] , CDbl(View_GIS_Union.[Longitude_GIS]) AS LongitudeGIS, CDbl(View_GIS_Union.[Latitude-SHLBHL]) AS LatitudeSHLBHL, CDbl(View_GIS_Union.[Longitude-SHLBHL]) AS LongitudeSHLBHL, " & _
"  View_GIS_Union.Well_County, View_GIS_Union.FIPS_State, View_GIS_Union.FIPS_County, View_GIS_Union.[Well Status] as Well_Status, Now() AS Publish_Date,  View_GIS_Union.API_Number, View_GIS_Union.NodeID, View_GIS_Union.Formation "
mySQL = mySQL & " INTO Regulatory_GIS IN 
mySQL = mySQL & " ORDER BY View_GIS_Union.St, View_GIS_Union.Well_Name, View_GIS_Union.SHLBHL, View_GIS_Union.ReqFin;"
Debug.Print mySQL

80        MsgBox "Before Delete there were " & CountRecords(DBPath, TblName) & " Records with timestamp date of " & OldestDate(DBPath, TblName), vbOKOnly + vbInformation, "Step 1 of 3  Update GIS database located at: " & DBPath
100      Result = DeleteTableFromBackEnd(DBPath, TblName)
            ' add linked table to populate - this is used to report what is in the GIS database
            DoEvents
            
110       MsgBox "Old GIS data Table deleted status is : " & Result & "   Verify zero records:  There are " & CountRecords(DBPath, TblName) & " Records ", vbOKOnly + vbInformation, "Step 2 of 3  Update GIS database located at: " & DBPath
130      CurrentDb.Execute mySQL
             'Debug.Print " Err.description " & Err.Description ' no errors - but "You do not have exclusive access to the database at this time" if switch to design mode.
140       MsgBox "GIS Data updated status is : " & Result & "   There are " & CountRecords(DBPath, TblName) & " Records     New record Timestamp is: " & OldestDate(DBPath, TblName), vbOKOnly + vbInformation, "Step 3 of 3  Update GIS database located at: " & DBPath
160      DoCmd.Hourglass False
PROC_EXIT:
170       On Error Resume Next
180         DoCmd.Hourglass False
190       Exit Sub
PROC_ERROR:
200       Select Case Err.Number
              Case 3010
210                 MsgBox "The table was not delete before refreshing it, possibly due to network delay please try again", "Update Remote DB"
220           Case Else
230                 MsgBox " please make a note: " & Err.Description, "Unknown Error"
240               Resume PROC_EXIT
250       End Select
End Sub
 
You can execute a query from one location to bring data into another DB
<define sql code > INTO Regulatory_GIS IN
CurrentDb.Execute mySQL

Look at the INTO statement

Code:
Private Sub cmd_Update_GIS_DB_Click()
      Dim mySQL As String
      Dim DBPath As String
      Dim Result
      Dim TblName As String
      Dim RecordCount As Long
      Dim RecordCountMessage
10    On Error GoTo PROC_EXIT
20    DoCmd.Hourglass True
30       DBPath = "X:\Tax\Audits\Regulatory_GIS.accdb"     
40       TblName = "Regulatory_GIS"
          ' Only change path here <<<<<<<<<<<<<<<<<<<  Database path and Table Name   >>>>>>>>>>>>>>>>>>>>>>>>>
        mySQL = "SELECT View_GIS_Union.ObjectID, View_GIS_Union.St, View_GIS_Union.Well_Name, View_GIS_Union.SHLBHL, View_GIS_Union.ReqFin, " & _
"CDbl([View_GIS_Union].[Latitude_GIS]) AS [LatitudeGIS] , CDbl(View_GIS_Union.[Longitude_GIS]) AS LongitudeGIS, CDbl(View_GIS_Union.[Latitude-SHLBHL]) AS LatitudeSHLBHL, CDbl(View_GIS_Union.[Longitude-SHLBHL]) AS LongitudeSHLBHL, " & _
"  View_GIS_Union.Well_County, View_GIS_Union.FIPS_State, View_GIS_Union.FIPS_County, View_GIS_Union.[Well Status] as Well_Status, Now() AS Publish_Date,  View_GIS_Union.API_Number, View_GIS_Union.NodeID, View_GIS_Union.Formation "
mySQL = mySQL & " INTO Regulatory_GIS IN 
mySQL = mySQL & " ORDER BY View_GIS_Union.St, View_GIS_Union.Well_Name, View_GIS_Union.SHLBHL, View_GIS_Union.ReqFin;"
Debug.Print mySQL

80        MsgBox "Before Delete there were " & CountRecords(DBPath, TblName) & " Records with timestamp date of " & OldestDate(DBPath, TblName), vbOKOnly + vbInformation, "Step 1 of 3  Update GIS database located at: " & DBPath
100      Result = DeleteTableFromBackEnd(DBPath, TblName)
            ' add linked table to populate - this is used to report what is in the GIS database
            DoEvents
            
110       MsgBox "Old GIS data Table deleted status is : " & Result & "   Verify zero records:  There are " & CountRecords(DBPath, TblName) & " Records ", vbOKOnly + vbInformation, "Step 2 of 3  Update GIS database located at: " & DBPath
130      CurrentDb.Execute mySQL
             'Debug.Print " Err.description " & Err.Description ' no errors - but "You do not have exclusive access to the database at this time" if switch to design mode.
140       MsgBox "GIS Data updated status is : " & Result & "   There are " & CountRecords(DBPath, TblName) & " Records     New record Timestamp is: " & OldestDate(DBPath, TblName), vbOKOnly + vbInformation, "Step 3 of 3  Update GIS database located at: " & DBPath
160      DoCmd.Hourglass False
PROC_EXIT:
170       On Error Resume Next
180         DoCmd.Hourglass False
190       Exit Sub
PROC_ERROR:
200       Select Case Err.Number
              Case 3010
210                 MsgBox "The table was not delete before refreshing it, possibly due to network delay please try again", "Update Remote DB"
220           Case Else
230                 MsgBox " please make a note: " & Err.Description, "Unknown Error"
240               Resume PROC_EXIT
250       End Select
End Sub
Hi and thanks for your help
but in fact i couldn't understand your codes:confused::o
If you could make an example for me, I appreciate you.
Let me once again express my issue:
1- have a table with name "T_BackUpTables" in my db that save table names that i enter them manually
2- for each record in "T_BackUpTables" search in "BackUp.mdb" that it is in for example "D:\BackUps\" foulder and see the table with that name exists or not, if exists go to next step, else go to next record in "T_BackUpTables"
3- delete the table with that name from my current db and import the table from "BackUp.mdb" in to my current db
thanks again for your help:)
 
I've made ​​the backup and recovery process that may be difficult for anyone to solve.
also there is useful modules.
 

Attachments

Users who are viewing this thread

Back
Top Bottom