need help with loop inserts with mysql

icemonster

Registered User.
Local time
Today, 17:14
Joined
Jan 30, 2010
Messages
502
so i am getting an error 438 with this one, anyone take a second look and tell me what's wrong? can't think straight at the moment, having gout attack :(

Code:
                Set ctl = Me.lstregclass
                For Each varItem In ctl.ItemSelected
                    strSQL = "INSERT INTO tbl_class_reg_student " & _
                             "(class_reg_stud_id_sched_class_main, class_reg_stud_id_student, class_reg_stud_createdon) VALUES (" & ctl & ", " & Form_frm_details_student.txtstudentid & ", Now());"
                    .Execute strSQL, , adCmdText + adExecuteNoRecords
                    strSQL = "SELECT Last_Insert_ID();"
                        With .Execute(strSQL, , adCmdText)
                            If Not (.BOF And .EOF) Then
                                lngLastClassRegStudentID = .Fields(0)
                            Else
                                ' Abort
                            End If
                        .Close
                        End With
                        
                    strSQL = "SELECT tbl_sched_class_main_student_status " & _
                             "(schedclsmnstudstat_id_class_reg_student, schedclsmnstudstat_id_class_status_type, schedclsmnstudstat_date, schedclsmnstudstat_createdon) VALUES (" & lngLastClassRegStudentID & ", 1, '" & Format(Date, "yyyymmdd") & "', Now());"
                    .Execute strSQL, , adCmdText + adExecuteNoRecords

                Next varItem
 

Users who are viewing this thread

Back
Top Bottom