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