accessNator
Registered User.
- Local time
- Yesterday, 21:55
- Joined
- Oct 17, 2008
- Messages
- 132
I am looping through a TABLE1 and in that recordset, I am inserting those values in another table called TABLE2. But it seems when I attempt to add the new record in TABLE2, it seems to hang and I cant figure it out. I have narrowed it down that if I COMMENT out the .update, my code will loop through the rst1 for TABLE1.
For some reason on the .UPDATE it just hangs. I eventually get an ODBC--Call Failed. [Microsoft][ODBC SQL Server Driver]Query timeout expirted(#0) Please contact your administrator.
Both tables are link tables to a SQL Server tables.
Here is my code:
For some reason on the .UPDATE it just hangs. I eventually get an ODBC--Call Failed. [Microsoft][ODBC SQL Server Driver]Query timeout expirted(#0) Please contact your administrator.
Both tables are link tables to a SQL Server tables.
Here is my code:
Code:
Private Sub InsertRecord()
Dim db As DAO.Database
Set db = CurrentDb
Dim rst1 As DAO.Recordset
Dim Table1 As String
Table1 = "dbo_tmpLifeLine"
Dim rst2 As DAO.Recordset
Dim Table2 As String
Table2 = "dbo_WorksheetHeader"
Set rst1 = db.OpenRecordset(Table1, dbOpenDynaset)
If Not (rst1.EOF And rst1.BOF) Then
rst1.MoveFirst
End If
Do Until rst1.EOF = True
Set rst2 = db.OpenRecordset(Table2, dbOpenDynaset, dbSeeChanges)
With rst2
.AddNew
![FiscalYearID] = rst1![FiscalYearID]
![companyid] = Me.txtCompanyID
![RevenueDataMonth] = rst1![DataMonth]
![RevenueDataYear] = rst1![DataYear]
![NumberOfMonths] = 1
![WorksheetTypeID] = 2
.Update
End With
rst2.Close
rst1.MoveNext
Loop
rst1.Close
Set rst1 = Nothing
Set rst2 = Nothing
Set db = Nothing
End Sub