I already input grades for the first student and the all grade information will save in the database. but when i'm trying to input grades for the other student i can't save the grade but there is no error shown.

Private Sub cmdSave_Click()
On Error Resume Next

If Val(txtcount.Text) = 0 Then
    Text(1).Enabled = False
    If Me.AdodcGrade.Recordset.EOF = True Then

    With AdodcGrade
    .Recordset.AddNew
    .Recordset.Fields("Fullname") = lblStudent.Caption
    .Recordset.Fields("Periodical") = txtPer.Text
    .Recordset.Fields("Art") = Text(0).Text
    .Recordset.Fields("English") = Text1(0).Text
    .Recordset.Fields("Filipino") = Text2(0).Text
    .Recordset.Fields("Hekasi") = Text3(0).Text
    .Recordset.Fields("Math") = Text4(0).Text
    .Recordset.Fields("Music") = Text5(0).Text
    .Recordset.Fields("PE") = Text6(0).Text
    .Recordset.Fields("Science") = Text7(0).Text
    .Recordset.Fields("Total") = Text8(0).Text
    .Recordset.Update
    .Refresh
    .Refresh
        Form2.Adodc1.Refresh
    End With
    If Me.AdodcRec.Recordset.EOF = True Then

    With AdodcRec
    .Recordset.AddNew
    .Recordset.Fields("Fullname") = lblStudent.Caption
    .Recordset.Fields("1st") = Text8(0).Text
    .Recordset.Fields("2nd") = Text8(1).Text
    .Recordset.Fields("3rd") = Text8(2).Text
    .Recordset.Fields("4th") = Text8(3).Text
    .Recordset.Fields("Total") = txttotalGen.Text
    .Recordset.Fields("Gen_Average") = txtTotalAverage.Text
    .Recordset.Update
    .Refresh
    .Refresh
     Form2.Adodc2.Refresh
    End With
    End If
    End If
        MsgBox "Save"

ElseIf Val(txtcount.Text) = 1 Then
If Me.AdodcGrade.Recordset.EOF = True Then

    With AdodcGrade
    .Recordset.AddNew
    .Recordset.Fields("Fullname") = lblStudent.Caption
    .Recordset.Fields("Art") = Text(1).Text
    .Recordset.Fields("English") = Text1(0).Text
    .Recordset.Fields("Filipino") = Text2(0).Text
    .Recordset.Fields("Hekasi") = Text3(0).Text
    .Recordset.Fields("Math") = Text4(0).Text
    .Recordset.Fields("Music") = Text5(0).Text
    .Recordset.Fields("PE") = Text6(0).Text
    .Recordset.Fields("Science") = Text7(0).Text
    .Recordset.Update
    .Refresh
    End With
    MsgBox "Save"
    End If
ElseIf Val(txtcount.Text) = 2 Then
If Me.AdodcGrade.Recordset.EOF = True Then

    With AdodcGrade
    .Recordset.AddNew
    .Recordset.Fields("Fullname") = lblStudent.Caption
    .Recordset.Fields("Art") = Text(2).Text
    .Recordset.Fields("English") = Text1(0).Text
    .Recordset.Fields("Filipino") = Text2(0).Text
    .Recordset.Fields("Hekasi") = Text3(0).Text
    .Recordset.Fields("Math") = Text4(0).Text
    .Recordset.Fields("Music") = Text5(0).Text
    .Recordset.Fields("PE") = Text6(0).Text
    .Recordset.Fields("Science") = Text7(0).Text
    .Recordset.Update
    .Refresh
    .Refresh
    End With
    MsgBox "Save"
    End If
ElseIf Val(txtcount.Text) = 3 Then
If Me.AdodcGrade.Recordset.EOF = True Then

    With AdodcGrade
    .Recordset.AddNew
    .Recordset.Fields("Fullname") = lblStudent.Caption
    .Recordset.Fields("Art") = Text(3).Text
    .Recordset.Fields("English") = Text1(0).Text
    .Recordset.Fields("Filipino") = Text2(0).Text
    .Recordset.Fields("Hekasi") = Text3(0).Text
    .Recordset.Fields("Math") = Text4(0).Text
    .Recordset.Fields("Music") = Text5(0).Text
    .Recordset.Fields("PE") = Text6(0).Text
    .Recordset.Fields("Science") = Text7(0).Text
    .Recordset.Update
    .Refresh
    End With
    MsgBox "Save"
    End If
End If

End Sub

Recommended Answers

All 2 Replies

I think your problem has to do with the current record pointer on your recordset objects. In every case, you check to see if you have an EOF condition. Since you haven't advanced the record pointer with a ".movenext" then you will never be at EOF.

On a completely different note, you could probably collapse your gigantic IF...ELSIF structure by testing the value of txtcount.Text at the top (and erroring out if it's not valid) then using .Recordset.Fields("Art") = Text(Val(txtcount.Text)).Text instead of hard-coding.

Hope this helps! Good luck!

but when i'm trying to input grades for the other student i can't save the grade but there is no error shown

.
it cause you using "On Error Resume Next" statment on line 2.
Delete this line and you will know what the error is if error detected.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.