I want to be able to connect to a ADP db with SQL table from an MDB. I have to create a recordset from the sql table and put the selected records into a mdb table. I've been using DAO in the mdb. I have the following code to show you what I have tried.
Also, there are some tables I need to grab all the data, so can I do this with fewer lines of code like using a docmd line?
Thanks, Bob
Private Sub cmdImportTables_Click()
Dim sqlstring As String
'Dim rsCCC As Recordset
Dim rsCCCLocal As Recordset
sqlstring = "SELECT CertifiedClassConstruction.* FROM CertifiedClassConstruction"
rsCCC.Open sqlstring, strcnn, adOpenStatic, adLockReadOnly
'Set dbProject = "Provider=sqloledb; Data Source=SQL_DEV;Initial Catalog=ForrestDevelopment;User Id=sa"
'Set rsCCC = dbProject.OpenRecordset("select CertifiedClassConstruction.* from CertifiedClassConstruction", dbOpenStatic)
If Not rsCCC.EOF Then
rsCCC.MoveFirst
End If
While Not rsCCC.EOF
Set dbCurrent = CurrentDb()
Set rsCCCLocal = dbCurrent.OpenRecordset("SELECT CertifiedClassConstruction.* FROM CertifiedClassConstruction", dbOpenDynaset)
rsCCCLocal.AddNew
rsCCCLocal!CertifiedClass = rsCCC!CertifiedClass
rsCCCLocal!Description = rsCCC!Description
rsCCCLocal.Update
rsCCC.MoveNext
rsCCCLocal.Close
Set rsCCCLocal = Nothing
Wend
rsCCC.Close
Set rsCCC = Nothing
End Sub
Also, there are some tables I need to grab all the data, so can I do this with fewer lines of code like using a docmd line?
Thanks, Bob
Private Sub cmdImportTables_Click()
Dim sqlstring As String
'Dim rsCCC As Recordset
Dim rsCCCLocal As Recordset
sqlstring = "SELECT CertifiedClassConstruction.* FROM CertifiedClassConstruction"
rsCCC.Open sqlstring, strcnn, adOpenStatic, adLockReadOnly
'Set dbProject = "Provider=sqloledb; Data Source=SQL_DEV;Initial Catalog=ForrestDevelopment;User Id=sa"
'Set rsCCC = dbProject.OpenRecordset("select CertifiedClassConstruction.* from CertifiedClassConstruction", dbOpenStatic)
If Not rsCCC.EOF Then
rsCCC.MoveFirst
End If
While Not rsCCC.EOF
Set dbCurrent = CurrentDb()
Set rsCCCLocal = dbCurrent.OpenRecordset("SELECT CertifiedClassConstruction.* FROM CertifiedClassConstruction", dbOpenDynaset)
rsCCCLocal.AddNew
rsCCCLocal!CertifiedClass = rsCCC!CertifiedClass
rsCCCLocal!Description = rsCCC!Description
rsCCCLocal.Update
rsCCC.MoveNext
rsCCCLocal.Close
Set rsCCCLocal = Nothing
Wend
rsCCC.Close
Set rsCCC = Nothing
End Sub