Open the table:
Set rsResponses = New ADODB.Recordset
With rsResponses
.CursorLocation = adUseServer
.CursorType = adOpenForwardOnly
.LockType = adLockOptimistic
.Open sCont, dbData, , , adCmdText
End With
Duplicate the found records, changing the ProfID field:
sCont = "ProfID = " & lOrgID
With rsResponses
.Filter = sCont
Do While Not .BOF And Not .EOF
lQuestID = .Fields("QuestID")
lAnsID = .Fields("AnsID")
sComments = .Fields("Comments")
sGC = .Fields("GroupCode")
sCont = "SET NOCOUNT ON; INSERT INTO " & sTDResponses & " (QuestID,MagID,ProfID,AnsID,Comments,GroupCode)" _
& " VALUES (" & lQuestID & "," & lMagID & "," & lNewID & "," & lAnsID & "," _
& "'" & sComments & "','" & sGC & "')"
Set rsTemp = dbData.Execute(sCont)
Set rsTemp = Nothing
.MoveNext
Loop
.Filter = ""
End With
|