AndrewDotto
Registered User.
- Local time
- Today, 20:59
- Joined
- Nov 24, 2011
- Messages
- 14
Hi Guys,
I've got the below code
I've edited it down for your ease... its a biiiig function. Anyway, the end result i'm wanting is to copy all the records in the recordset into the selected table. When i run it, it only enters the first entry into the table, but enters it
times into the table, depending on how many records are in the recordset.
Any Ideas?
Thanks,
Andrew
I've got the below code
Code:
Private Sub WorkOrder_AfterUpdate()
Dim strsql As String
Dim rst As ADODB.Recordset
Dim taskid As String
Dim JobDesc As String
Dim sql As String
Set rst = New ADODB.Recordset
rst.ActiveConnection = CurrentProject.Connection
strsql = "SELECT CMD_SOR_REF,CMD_CURRENT_COMPLETED,CMD_ORIGINAL_QUANTITY,CMD_DESCRIPTION FROM TASKDBA_WM_COMPLETION_DETAIL WHERE CMD_JOB_REF =" & Chr(34) & taskid & Chr(34) & ";"
rst.Open (strsql)
sql = "INSERT INTO TblJobDetails (ID,JobDetails,SOR,Description,ordered,completed) VALUES (' " & [Forms]![frmresponsivepc]![ID] & "','" & JobDesc & "','" & rst!cmd_sor_ref & "','" & rst!cmd_description & "'," & Chr(34) & rst!cmd_original_quantity & Chr(34) & "," & Chr(34) & rst!cmd_current_completed & Chr(34) & ");"
rst.MoveFirst
Do Until rst.EOF
DoCmd.RunSQL (sql)
Debug.Print rst.RecordCount
Debug.Print sql
rst.MoveNext
Debug.Print sql
Loop
End
rst.Close
I've edited it down for your ease... its a biiiig function. Anyway, the end result i'm wanting is to copy all the records in the recordset into the selected table. When i run it, it only enters the first entry into the table, but enters it

Any Ideas?
Thanks,
Andrew