R
Robert Rupe
I am having a problem appending some data from a table in a remote db
to a table in the local db.
My code is:
Private Sub pvtRefreshSubDepts()
Dim strQuery2 As String
Dim rs As ADODB.Recordset
Dim cn As ADODB.Connection
On Error GoTo pvtRefreshSubDepts_Err
Set rs = New ADODB.Recordset
Set cn = New ADODB.Connection
cn.Provider = "Microsoft.Jet.OLEDB.4.0"
cn.ConnectionString =
"DataSource='\\usflo1gtsfp01\Ifs_flo1_grp\IFS Learning
Maps\Database\LMS_10_Base.mdb'"
cn.Open
strQuery2 = "SELECT * FROM tblSubDept;"
rs.Open strQuery2, cn, adOpenStatic, adLockReadOnly, adCmdText
strQuery = "INSERT INTO tblSubDept (SubDeptIdx, SubDeptName,
DeptIdx) " & _
"SELECT rs.SubDeptIdx, rs.SubDeptName, rs.DeptIdx " & _
"FROM rs;"
DoCmd.RunSQL strQuery
When I run the SQL I get an error stating the system can't find rs as
a query or table. Yet I can loop through the records and assign the
data just fine using the rs designation for the recordset. Can anyone
see what is wrong with this?
to a table in the local db.
My code is:
Private Sub pvtRefreshSubDepts()
Dim strQuery2 As String
Dim rs As ADODB.Recordset
Dim cn As ADODB.Connection
On Error GoTo pvtRefreshSubDepts_Err
Set rs = New ADODB.Recordset
Set cn = New ADODB.Connection
cn.Provider = "Microsoft.Jet.OLEDB.4.0"
cn.ConnectionString =
"DataSource='\\usflo1gtsfp01\Ifs_flo1_grp\IFS Learning
Maps\Database\LMS_10_Base.mdb'"
cn.Open
strQuery2 = "SELECT * FROM tblSubDept;"
rs.Open strQuery2, cn, adOpenStatic, adLockReadOnly, adCmdText
strQuery = "INSERT INTO tblSubDept (SubDeptIdx, SubDeptName,
DeptIdx) " & _
"SELECT rs.SubDeptIdx, rs.SubDeptName, rs.DeptIdx " & _
"FROM rs;"
DoCmd.RunSQL strQuery
When I run the SQL I get an error stating the system can't find rs as
a query or table. Yet I can loop through the records and assign the
data just fine using the rs designation for the recordset. Can anyone
see what is wrong with this?