0% found this document useful (0 votes)
39 views3 pages

Bài 10

This document contains code for navigating records in a database table called "Mon_hoc". It defines subroutines to move to the first, previous, next, and last records. Each subroutine opens a recordset on the "Mon_hoc" table, retrieves the field values for the current record, and updates four text boxes (txtma, txtten, txtso, txtso1) with the record's data.

Uploaded by

Ngân Đỗ
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views3 pages

Bài 10

This document contains code for navigating records in a database table called "Mon_hoc". It defines subroutines to move to the first, previous, next, and last records. Each subroutine opens a recordset on the "Mon_hoc" table, retrieves the field values for the current record, and updates four text boxes (txtma, txtten, txtso, txtso1) with the record's data.

Uploaded by

Ngân Đỗ
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

Bi 10: Mn_hc

Private Sub back_Click() Dim db As Database Dim rs As DAO.Recordset Dim vt%, i% Set db = OpenDatabase("E:\QLDiem.mdb") Set rs = db.OpenRecordset("select *from Mon_hoc") vt = txtso1 If (vt = 1) Then Exit Sub i=0 Do Until rs.EOF i=i+1 If (i = vt - 1) Then txtma = rs("mamon") txtten = rs("tenmon") txtso = rs("sodvht") txtso1 = i Exit Do End If rs.MoveNext Loop rs.Close db.Close End Sub Private Sub cuoi_Click() Dim db As Database Dim rs As DAO.Recordset Dim vt As TextBox, i% Set db = OpenDatabase("E:\QLDiem.mdb") Set rs = db.OpenRecordset("select *from Mon_hoc") If rs.EOF = True Then txtso1 = "" Else rs.MoveLast txtso1 = rs.RecordCount txtma = rs("mamon") txtten = rs("tenmon") txtso = rs("sodvht") End If rs.Close db.Close

End Sub Private Sub dau_Click() Dim db As Database Dim rs As DAO.Recordset Dim vt As TextBox, i% Set db = OpenDatabase("E:\QLDiem.mdb") Set rs = db.OpenRecordset("select *from Mon_hoc") If rs.EOF = True Then txtso1 = "" Else txtso1 = 1 txtma = rs("mamon") txtten = rs("tenmon") txtso = rs("sodvht") End If End Sub Private Sub Form_Load() Dim db As Database Dim rs As DAO.Recordset Dim vt As TextBox, i% Set db = OpenDatabase("E:\QLDiem.mdb") Set rs = db.OpenRecordset("select *from Mon_hoc") txtso1 = 1 txtma = rs("mamon") txtten = rs("tenmon") txtso = rs("sodvht") End Sub Private Sub next_Click() Dim db As Database Dim rs As DAO.Recordset Dim vt%, i% Set db = OpenDatabase("E:\QLDiem.mdb") Set rs = db.OpenRecordset("select *from Mon_hoc") vt = txtso1 i=0 Do Until rs.EOF i=i+1 If (i = vt + 1) Then txtma = rs("mamon") txtten = rs("tenmon")

txtso = rs("sodvht") txtso1 = i Exit Do End If rs.MoveNext Loop rs.Close db.Close End Sub

You might also like