Qwert0000
Technical User
- Oct 24, 2003
- 30
I have a table where I have the "where" clause of my sql statement stored as one of the fields. I can append to a table via a form when running my sql clause based on the current record.
I would like to run this code as a loop on a on dirty trigger on a seperate form. Im not realy sure how to loop though each record of the recordset and run the code one record at a time.
The table I am appending to uses a derived key so I am not worried about writing duplicate records, but am just adding revenent records based on new status.
Below is the code Im playing with, if some one can point me in the right direction
Dim SQLINSERT, WhereSQL As String
Dim rs As Object
Dim School, Target as Long
Set rs = [RequiredTrainingList].RecordsetClone
Loop
School = [RequiredTrainingList].SchoolID
Target = [RequiredTrainingList].TargetAdjust
WhereSQL = [RequiredTrainingList].SQL
SQLINSERT = "INSERT INTO [TrainingReqs] ( RecSchoolID, SSN, SchoolRecNumber, TargetDate ) " & _
"SELECT (([Personnel].RecNumber*1000) + [RequiredSchoolList].SchoolID), [Personnel}.SSN, " & School & ", (DateAdd(""d"", " & Target & ", Date$()))" & _
"FROM [Personnel] " & _
"Where " & Wheresql & " and [Personnel}.SSN = '" & Me.SSNtxt & "' ;"
DoCmd.RunSQL SQLINSERT
End Loop
I would like to run this code as a loop on a on dirty trigger on a seperate form. Im not realy sure how to loop though each record of the recordset and run the code one record at a time.
The table I am appending to uses a derived key so I am not worried about writing duplicate records, but am just adding revenent records based on new status.
Below is the code Im playing with, if some one can point me in the right direction
Dim SQLINSERT, WhereSQL As String
Dim rs As Object
Dim School, Target as Long
Set rs = [RequiredTrainingList].RecordsetClone
Loop
School = [RequiredTrainingList].SchoolID
Target = [RequiredTrainingList].TargetAdjust
WhereSQL = [RequiredTrainingList].SQL
SQLINSERT = "INSERT INTO [TrainingReqs] ( RecSchoolID, SSN, SchoolRecNumber, TargetDate ) " & _
"SELECT (([Personnel].RecNumber*1000) + [RequiredSchoolList].SchoolID), [Personnel}.SSN, " & School & ", (DateAdd(""d"", " & Target & ", Date$()))" & _
"FROM [Personnel] " & _
"Where " & Wheresql & " and [Personnel}.SSN = '" & Me.SSNtxt & "' ;"
DoCmd.RunSQL SQLINSERT
End Loop