Student information management system-error '20140901'

Source: Internet
Author: User

This error is the most common one.

First, an error occurs when the form for modifying XX information is opened. It is found on the internet that there is no data in the recordset. After adding a group of information, you can open the modification, but this does not solve the fundamental problem. I modified it like this: Write a set of judgment statements and click the event in the menu item of frmmain.

Private sub modifycinfomenu_click () txtsql = "select * From class_info" set MRC = executesql (txtsql, msgtext) 'to obtain the class table and display 'judge whether the record is empty, if it is blank, a prompt box is displayed. After confirmation, an information form is displayed. If MRC. recordcount = 0 then msgbox "the record is empty. Please add it first! ", Vbokonly + vbexclamation," warning "MRC. close set MRC = nothing frmaddclassinfo. show exit sub else frmmodifyclassinfo. show end ifend subprivate sub modifycoursemenu_click () txtsql = "select * From course_info" set MRC = executesql (txtsql, msgtext) 'to obtain the Course table, and display 'judge whether the record is empty, if MRC. recordcount = 0 then msgbox "the record is empty. Please add it first! ", Vbokonly + vbexclamation," warning "MRC. Close set MRC = nothing frmaddcourseinfo. Show exit sub else frmmodifycourseinfo. Show end ifend sub

Make other similar changes.

Second, when deleting data, there will be no errors when deleting more than two records, but an error will occur when deleting the last record.

Method 1: Use the error processing Statement (premise: although an error occurs after you click the delete button, the record has been deleted when you re-open it)

Private sub deletecommand_click () on error goto d_err mybookmark = MRC. bookmark' mark str2 $ = msgbox ("Do you want to delete the current record? ", Vbokcancel," delete current record ") if str2 $ = vbok then... end ifd_exit: Exit sub unload med_err: txtsid. TEXT = "" 'clear the text boxes (optional) txtname. TEXT = ""... msgbox "record is empty. ", Vbokonly + vbexclamation," warning "Goto d_exitend sub

Method 2: Write a judgment statement to determine whether it is the last record.

Private sub deletecommand_click () mybookmark = MRC. Bookmark str2 $ = msgbox ("Do you want to delete the current record? ", Vbokcancel," delete current record ") if str2 $ = vbok then MRC. movenext 'determines whether it is the last record if MRC. EOF then MRC. moveprevious MRC. moveprevious if MRC. if BOF then' is set, delete it to avoid executing the call viewdata MRC statement. movenext MRC. delete msgbox "the record is already empty.,", vbokonly + vbexclamation, "warning" unload me else MRC. movefirst mybookmark = MRC. bookmark MRC. movelast MRC. delete MRC. bookmark = mybookmark MRC. close txtsql = "select * From class_info" set MRC = executesql (txtsql, msgtext) MRC. movelast call viewdata end if else mybookmark = MRC. bookmark MRC. moveprevious MRC. delete MRC. bookmark = mybookmark MRC. close txtsql = "select * From class_info" set MRC = executesql (txtsql, msgtext) MRC. movelast call viewdata end if else MRC. bookmark = mybookmark call viewdata end ifend sub

The delete button code in other forms can be modified similarly.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.