How can I pull data from an ODBC Connection, but write to a table in my access database? I use to be able to setup a link under tables to the remote file and then just allow access to handle pulling the data and since the connection is using the current database it just writes the table in the session.
Example:
I would then do whatever I needed. The problem now is that I cannot preset the link in Access. I can connect with the following code:
Since the connection is to the remote data if I do an Insert it is going to try to create the table there and I do not have access to do that. I could set all the data to variables and then set those variables to a table in this database, but I would rather not if I can avoid it. Can any one help?
Example:
Code:
Dim Conn As ADODB.Connection
Dim rsTable As ADODB.Recordset
Dim strSQL As String
Set Conn = CurrentProject.Connection
Set rsTable = New ADODB.Recordset
strSQL = ""
strSQL = strSQL & "Select *"
strSQL = strSQL & " Into TempTable_tbl" 'Table in Current Access Database"
strSQL = strSQL & " From RemoteTable;"
rsTable.Open strSQL, Conn, adOpenDynamic, adLockOptimistic
....
Code:
Dim Conn As ADODB.Connection
Dim rsTable As ADODB.Recordset
Dim strSQL As String
Set Conn = New ADODB.Connection
Set rsTable = New ADODB.Recordset
With Conn
.Provider = "MSDASQL"
.ConnectionString = "DSN=DSNNAME;"
.Open , MyUser, MyPassword
End With
strSQL = ""
strSQL = strSQL & "Select *"
strSQL = strSQL & " From RemoteTable;"
rsTable.Open strSQL, Conn, adOpenDynamic, adLockOptimistic
...