ARRR! I know that this was working at one time, then I tried to tweak it and everything went to hell in a handbasket. Can I say that on this forum? Anyways, I am importing XML files into a temporary table (because the data must go into related tables and the import funtion is unable to handle that due to autonumbering, yada yada yada...).
From this temporary table I use code to Insert a new record to the correct table. When the autonumber is generated I grab the autonumber and use it when adding the second series of data (in the related table, with the related autonumber.
Here's the code:
The problems I am getting are that either nothing is happening at all or that I get 60000 records in the first table but nothing in the second.
CG
From this temporary table I use code to Insert a new record to the correct table. When the autonumber is generated I grab the autonumber and use it when adding the second series of data (in the related table, with the related autonumber.
Here's the code:
Code:
Private Sub Command5_Click()
Option Explicit
Dim HoldID As Long, rst As DAO.Recordset
Dim rstSrc As DAO.Recordset
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset( _
"SELECT * FROM InvoiceID WHERE 1=0")
Set rstSrc = dbs.OpenRecordset( _
"SELECT * FROM Invoice_Temp WHERE 1=0")
With rstSrc
If (.RecordCount) Then
.MoveFirst
Do Until .EOF
rst.AddNew
rst!Notes = .Fields!Notes
rst!Customer = .Fields!Customer
HoldID = rst!TestID
rst.Update
Loop
End If
End With
rst.Close
Set rst = Nothing
Dim rst2 As DAO.Recordset, rstSrc2 As DAO.Recordset
Set dbs = CurrentDb
Set rst2 = dbs.OpenRecordset( _
"SELECT * FROM [Invoice Details] WHERE 1=0")
Set rstSrc2 = dbs.OpenRecordset( _
"SELECT * FROM Invoice_Temp WHERE 1=0")
With rstSrc2
If (.RecordCount) Then
.MoveFirst
Do Until .EOF
rst2.AddNew
rst2!InvoiceID = HoldID
rst2!ToolID = .Fields!ToolID
rst2.Update
Loop
End If
End With
rst2.Close
Set rst2 = Nothing
End Sub
The problems I am getting are that either nothing is happening at all or that I get 60000 records in the first table but nothing in the second.
CG
Last edited: