Skip to content

Instantly share code, notes, and snippets.

@alexander-arce
Created July 5, 2015 15:25
Show Gist options
  • Select an option

  • Save alexander-arce/864621bc2c3c1daa3618 to your computer and use it in GitHub Desktop.

Select an option

Save alexander-arce/864621bc2c3c1daa3618 to your computer and use it in GitHub Desktop.
MIgrate DB Acess
Private Sub Comando17_Click()
Dim sTblNm As String
Dim sTypExprt As String
Dim sCnxnStr As String, vStTime As Variant
Dim db As Database, tbldef As DAO.TableDef
On Error GoTo ExportTbls_Error
sTypExprt = "ODBC Database"
sCnxnStr = "ODBC;DSN=PostgreSQL35W;DATABASE=siafu;SERVER=127.0.0.1;PORT=5432;UID=postgres;PWD=postgres;CA=d;A6=;A7=100;A8=4096;B0=255;B1=8190;BI=0;C2=dd_;;CX=1c20502bb;A1=7.4-1"
vStTime = Timer
Application.Echo False, "Visual Basic code is executing."
Set db = CurrentDb()
For Each tbldef In db.TableDefs
Debug.Print tbldef.Name
sTblNm = tbldef.Name
DoCmd.TransferDatabase acExport, sTypExprt, sCnxnStr, acTable, sTblNm, LCase(sTblNm)
Next tbldef
' If DoCmd.TransferDatabase acExport, sTypExprt, sCnxnStr, acTable, sTblNm, sTblNm Is True Then
' Next tbldef
' Else
' MsgBox("Error exporting table " & tbldef)
' Next tbldef
' End If
MsgBox "Done!"
On Error GoTo 0
SmoothExit_ExportTbls:
Set db = Nothing
Application.Echo True
Exit Sub
ExportTbls_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure ExportTblsODST " & sTblNm
'Resume SmoothExit_ExportTbls
Resume Next
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment