I'm surprised you aren't getting errors either.... each time you append a parameter, you're adding a new one... the OLD ones are still there....
which is why the same values keep getting put in there.... solution is simple... re-arrange the code.
-tgCode:Set cn = New ADODB.Connection cn.ConnectionString = strConnection & App.Path & "\Membership.mdb" cn.Open Dim adoCommand As ADODB.Command Set adoCommand = New ADODB.Command strSQL = "INSERT INTO tbl_CourseList (Course_Month, Course_Date, " & _ "Course_Day, Course_Type, " & _ "Course_Venue, Course_Times, Course_Year)" & _ " Values (?, ?, ?, ?, ?, ?, ?)" With adoCommand .ActiveConnection = cn .CommandType = adCmdText .CommandText = strSQL .Prepared = True .Parameters.Append .CreateParameter(, adInteger, adParamInput, 50) .Parameters.Append .CreateParameter(, adDate, adParamInput, 50) .Parameters.Append .CreateParameter(, adVarChar, adParamInput, 50) .Parameters.Append .CreateParameter(, adVarChar, adParamInput, 50) .Parameters.Append .CreateParameter(, adVarChar, adParamInput, 50) .Parameters.Append .CreateParameter(, adVarChar, adParamInput, 50) .Parameters.Append .CreateParameter(, adVarChar, adParamInput, 50) End With For i = 0 To ctr - 1 iMonth = CInt(cmbMM(i).Text) dtDate = CDate(cmbDD(i).Text & "/" & cmbMM(i).Text & "/" & cmbYY(i).Text) strDay = cmbDay(i).Text strType = cmbType(i).Text strVenue = cmbVenue(i).Text strTimes = cmbTime1(i).Text & " to " & cmbTime2(i).Text & " - " & cmbTime3(i).Text & " to " & cmbTime4(i).Text strYear = cmbYY(i).Text With adoCommand .Parameters(0).Value = iMonth .Parameters(1).Value = dtDate .Parameters(2).Value = strDay .Parameters(3).Value = strType .Parameters(4).Value = strVenue .Parameters(5).Value = strTimes .Parameters(6).Value = strYear .Execute , , adCmdText + adExecuteNoRecords 'note: the last two arguments used for Execute here makes the execution of the command faster End With Next cn.Close Set cn = Nothing




Reply With Quote