Can you please help me with dis code?
I want to save record in the database by inputing data in the MSFlexgrid ..
Also it can accept null values..
Private Sub MSFlexGrid1_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case Is = 8
If MSFlexGrid1.Text <> "" Then MSFlexGrid1.Text = Mid(MSFlexGrid1.Text, 1, Len(MSFlexGrid1.Text) - 1)
Case Else
MSFlexGrid1.Text = MSFlexGrid1.Text & Chr(KeyAscii)
End Select
End Sub
Private Sub cmdOk_Click()
For i = 2 To MSFlexGrid1.Rows - 1
For j = 2 To MSFlexGrid1.Cols - 1
strSQL = "SELECT * from tblGrades where enroll_ID = " & CInt(MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 0))
Set recSet = New ADODB.Recordset
With recSet
.Open strSQL, Conn, adOpenKeyset, adLockOptimistic
.AddNew
Select Case j
Case Is = 1
!prelim_grade = ifIsNull(MSFlexGrid1.TextMatrix(i, j))
Case Is = 2
!midterm_grade = ifIsNull(MSFlexGrid1.TextMatrix(i, j))
Case Is = 3
!prefinal_grade = ifIsNull(MSFlexGrid1.TextMatrix(i, j))
Case Is = 4
!final_grade = ifIsNull(MSFlexGrid1.TextMatrix(i, j))
Case Is = 5
!gwa_grade = ifIsNull(MSFlexGrid1.TextMatrix(i, j))
End Select
.Update
.Close
End With
Next
Next
End Sub
I did not notice that db call was inside the nested loop. Not only is it hitting the db way to much but it is creating a new record for every cell in the grid.
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.