Student Management System - Error 3021

3021 is the emergence of problem bof or EOF, there is a real, or is the current record has been deleted, requires a current record.

First of all we have to find out what is the BOF and EOF

BOF refers to a record before the last recording position is the current object Recordset

EOF is the current recording position of the last record located after Recordset object

 

BOF with EOF return values ​​are:

BOF: true, indicates that the current position of the pointer in the row in front of

         False, indicating the current position of the pointer in the first row, the first row or the rear

EOF: True indicates the current position of the pointer after the last row in the

           False indicating the pointer is a position in the last row, or in front of the last row.

 

1. Find the record database is empty.

 

2. Find the data, delete records with Del command, then cited error occurs after Fields.

 

3. The command has moved to the database and then start with MovePrevious MoveFirst command or with MovePrevious.

 

4 has been moved to the database command starts after use or use MoveNext MoveLast MoveNext command.

 

It is not in the database data.

Private Sub Cmddelete_Click()          '删除

    str2$ = MsgBox("是否删除当前记录?", vbOKCancel, "删除当前记录")

    If str2$ = vbOK Then       '点击确定

        mrc.Delete             '删除记录

        mrc.MoveNext           '指针往下走

           If mrc.EOF Then     '判断是否删

            If mrc.RecordCount = 0 Then         '判断上边有没有记录


                                             '如果没有的话卸载窗体

              MsgBox "无记录!"

            Unload Me

            Else                           

            mrc.MoveFirst            '否则指向第一条记录

            Call viewData

            End If

     End If

    End If

End Sub

 

 

Published 14 original articles · won praise 0 · Views 660

Guess you like

Origin blog.csdn.net/weixin_42225180/article/details/103343818