Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 22 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
22
Dung lượng
272,5 KB
Nội dung
BÀI : Command _ DataGrid _ DataCombo Option Explicit DIM cn As New ADODB.Connection DIM rstBANG As New ADODB.Recordset DIM rstTheLoai As New ADODB.Recordset DIM cm As New ADODB.Command DIM flag As String Private Sub End_Click() KhoaDT Me, False CheCN Me, True DuaDLVaoTextBox End Sub Private Sub cmdFirst_Click() rstBANG.MoveFirst DuaDLVaoTextBox End Sub Private Sub cmdLast_Click() rstBANG.MoveLast DuaDLVaoTextBox End Sub Private Sub cmdLuu_Click() DIM strsql As String If flag = "them" Then strsql = "INSERT INTO Bang(Maso,matl,Ten,Soluong,dongia) Values ('" & txtMaso.Text & "','" & txtMatl.Text & "','" & txtTen.Text & "'," & txtsoluong.Text & "," & txtDongia.Text & ")" rstBANG.MoveFirst rstBANG.Find "Maso='" & txtMaso.Text & "'" If Not rstBANG.EOF Then MsgBox "Ma so da co san Co So Du Lieu" Exit Sub End If cm.ActiveConnection = cn cm.CommandText = strsql cm.CommandType = adCmdText cm.Execute ElseIf flag = "sua" Then strsql = "UPDATE BANG SET Matl='" & txtMatl.Text & "', Ten='" & txtTen.Text & "',Soluong=" & txtsoluong.Text & ",dongia=" & txtDongia.Text & " WHERE Maso='" & txtMaso.Text & "'" cm.ActiveConnection = cn cm.CommandText = strsql cm.CommandType = adCmdText cm.Execute End If CheCN Me, True KhoaDT Me, False rstBANG.Requery DuaDLVaoTextBox End Sub Private Sub cmdNext_Click() rstBANG.MoveNext DuaDLVaoTextBox End Sub Private Sub cmdPrevious_Click() rstBANG.MovePrevious DuaDLVaoTextBox End Sub Private Sub cmdSua_Click() CheCN Me, False 'txtMatl.Enabled = True dtcboTHELOAI.Enabled = True txtTen.Enabled = True txtsoluong.Enabled = True txtDongia.Enabled = True flag = "sua" End Sub Private Sub cmdThem_Click() KhoaDT Me, True CheCN Me, False XoaTextbox txtMatl.Enabled = False flag = "them" End Sub Private Sub cmdTim_Click() DIM gttim DIM rsttim As New ADODB.Recordset Set rsttim = rstBANG gttim = InputBox("Nhap vao ma so can tim :", "Tim bang") rsttim.MoveFirst rsttim.Find "maso='" & gttim & "'" If rsttim.EOF Then MsgBox "Khong tim thay" cmdLast_Click Else rstBANG.Bookmark = rsttim.Bookmark DuaDLVaoTextBox End If End Sub Private Sub cmdXoa_Click() DIM strsql As String strsql = "DELETE * FROM Bang WHERE Maso='" & txtMaso.Text & "'" cm.ActiveConnection = cn cm.CommandText = strsql cm.CommandType = adCmdText cm.Execute rstBANG.Requery DuaDLVaoTextBox End Sub Private Sub dtcboTHELOAI_Click(Area As Integer) rstTheLoai.MoveFirst rstTheLoai.Find "Theloai='" & dtcboTHELOAI.Text & "'" txtMatl.Text = rstTheLoai("matl") End Sub Private Sub dtgrdBANG_RowColChange(LastRow As Variant, ByVal LastCol As Integer) DuaDLVaoTextBox End Sub Private Sub Form_Load() cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='" & App.Path & "\video.mdb'" cn.CursorLocation = adUseClient cn.Open rstBANG.Open "Bang", cn, adOpenStatic, adLockOptimistic, adCmdTable Set dtgrdBANG.DataSource = rstBANG rstTheLoai.Open "TheLoai", cn, adOpenStatic, adLockOptimistic, adCmdTable Set dtcboTHELOAI.RowSource = rstTheLoai dtcboTHELOAI.ListField = "TheLoai" KhoaDT Me, False CheCN Me, True DuaDLVaoTextBox End Sub Sub DuaDLVaoTextBox() On Error Resume Next txtMaso.Text = rstBANG(0).Value txtMatl.Text = rstBANG(1).Value txtTen.Text = rstBANG(2).Value txtsoluong.Text = rstBANG(3).Value txtDongia.Text = rstBANG(4).Value rstTheLoai.MoveFirst rstTheLoai.Find "Matl='" & txtMatl.Text & "'" dtcboTHELOAI.Text = rstTheLoai.Fields(1).Value End Sub Sub XoaTextbox() txtMaso.Text = "" txtMatl.Text = "" txtTen.Text = "" txtsoluong.Text = "" txtDongia.Text = "" End Sub BÀI : Command _ DataList _ Datacombo Option Explicit DIM cn As New ADODB.Connection DIM rstBANG As New ADODB.Recordset DIM rstTheLoai As New ADODB.Recordset DIM cm As New ADODB.Command DIM flag As String Private Sub cmdBoqua_Click() KhoaDT Me, False CheCN Me, True DuaDLVaoTextBox End Sub Private Sub cmdFirst_Click() rstBANG.MoveFirst DuaDLVaoTextBox End Sub Private Sub cmdLast_Click() rstBANG.MoveLast DuaDLVaoTextBox End Sub Private Sub cmdLuu_Click() DIM strsql As String If flag = "them" Then strsql = "INSERT INTO Bang(Maso,matl,Ten,Soluong,dongia) Values ('" & txtMaso.Text & "','" & txtMatl.Text & "','" & txtTen.Text & "'," & txtsoluong.Text & "," & txtDongia.Text & ")" rstBANG.MoveFirst rstBANG.Find "Maso='" & txtMaso.Text & "'" If Not rstBANG.EOF Then MsgBox "Ma so da co san Co So Du Lieu" Exit Sub End If cm.ActiveConnection = cn cm.CommandText = strsql cm.CommandType = adCmdText cm.Execute ElseIf flag = "sua" Then strsql = "UPDATE BANG SET Matl='" & txtMatl.Text & "', Ten='" & txtTen.Text & "',Soluong=" & txtsoluong.Text & ",dongia=" & txtDongia.Text & " WHERE Maso='" & txtMaso.Text & "'" cm.ActiveConnection = cn cm.CommandText = strsql cm.CommandType = adCmdText cm.Execute End If CheCN Me, True KhoaDT Me, False rstBANG.Requery DuaDLVaoTextBox DuaDLVaoLV End Sub Private Sub cmdNext_Click() rstBANG.MoveNext DuaDLVaoTextBox End Sub Private Sub cmdPrevious_Click() rstBANG.MovePrevious DuaDLVaoTextBox End Sub Private Sub cmdSua_Click() CheCN Me, False 'txtMatl.Enabled = True dtcboTHELOAI.Enabled = True txtTen.Enabled = True txtsoluong.Enabled = True txtDongia.Enabled = True flag = "sua" End Sub Private Sub cmdThem_Click() KhoaDT Me, True CheCN Me, False XoaTextbox txtMatl.Enabled = False flag = "them" End Sub Private Sub cmdTim_Click() DIM gttim DIM rsttim As New ADODB.Recordset Set rsttim = rstBANG gttim = InputBox("Nhap vao ma so can tim :", "Tim bang") rsttim.MoveFirst rsttim.Find "maso='" & gttim & "'" If rsttim.EOF Then MsgBox "Khong tim thay" cmdLast_Click Else rstBANG.Bookmark = rsttim.Bookmark DuaDLVaoTextBox End If End Sub Private Sub cmdXoa_Click() DIM strsql As String strsql = "DELETE * FROM Bang WHERE Maso='" & txtMaso.Text & "'" cm.ActiveConnection = cn cm.CommandText = strsql cm.CommandType = adCmdText cm.Execute rstBANG.Requery DuaDLVaoTextBox End Sub Private Sub dtcboTHELOAI_Click(Area As Integer) rstTheLoai.MoveFirst rstTheLoai.Find "Theloai='" & dtcboTHELOAI.Text & "'" txtMatl.Text = rstTheLoai("matl") End Sub Private Sub Form_Load() cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='" & App.Path & "\video.mdb'" cn.CursorLocation = adUseClient cn.Open rstBANG.Open "Bang", cn, adOpenStatic, adLockOptimistic, adCmdTable rstTheLoai.Open "TheLoai", cn, adOpenStatic, adLockOptimistic, adCmdTable Set dtcboTHELOAI.RowSource = rstTheLoai dtcboTHELOAI.ListField = "TheLoai" KhoaDT Me, False CheCN Me, True DuaDLVaoTextBox DuaDLVaoLV End Sub Sub DuaDLVaoTextBox() On Error Resume Next txtMaso.Text = rstBANG(0).Value txtMatl.Text = rstBANG(1).Value txtTen.Text = rstBANG(2).Value txtsoluong.Text = rstBANG(3).Value txtDongia.Text = rstBANG(4).Value rstTheLoai.MoveFirst rstTheLoai.Find "Matl='" & txtMatl.Text & "'" dtcboTHELOAI.Text = rstTheLoai.Fields(1).Value End Sub Sub XoaTextbox() txtMaso.Text = "" txtMatl.Text = "" txtTen.Text = "" txtsoluong.Text = "" txtDongia.Text = "" End Sub Sub DuaDLVaoLV() lvwBANG.ListItems.Clear rstBANG.MoveFirst Do While Not rstBANG.EOF lvwBANG.ListItems.Add , , rstBANG(0).Value lvwBANG.ListItems(lvwBANG.ListItems.Count).ListSubItems.Add , , rstBANG(1).Value lvwBANG.ListItems(lvwBANG.ListItems.Count).ListSubItems.Add , , rstBANG(2).Value lvwBANG.ListItems(lvwBANG.ListItems.Count).ListSubItems.Add , , rstBANG(3).Value lvwBANG.ListItems(lvwBANG.ListItems.Count).ListSubItems.Add , , rstBANG(4).Value rstBANG.MoveNext Loop rstBANG.MoveFirst End Sub Private Sub lvwBANG_ItemClick(ByVal Item As MSComctlLib.ListItem) rstBANG.Move Item.Index - 1, rstBANG.Find "Maso='" & Item.Text & "'" If Not rstBANG.EOF Then txtMaso.Text = rstBANG(0).Value txtMatl.Text = rstBANG(1).Value txtTen.Text = rstBANG(2).Value txtsoluong.Text = rstBANG(3).Value txtDongia.Text = rstBANG(4).Value Else MsgBox "Mau tin khong co thuc" End If rstTheLoai.MoveFirst rstTheLoai.Find "Matl='" & txtMatl.Text & "'" dtcboTHELOAI.Text = rstTheLoai.Fields(1).Value End Sub BÀI : Chấm Công _ Command _DataGrid _ Datacombo Tháng năm : Thêm Mã nv : Xóa Mã cv : Sữa Số công : Tìm Tiền công : Lưu Bỏ qua Thoát Option Explicit DIM cn As New ADODB.Connection DIM rstCHAMCONG As New ADODB.Recordset DIM rstDMCV As New ADODB.Recordset DIM cm As New ADODB.Command DIM flag As String Private Sub cmdBoqua_Click() KhoaDT Me, False CheCN Me, True DuaDLVaoTextBox End Sub Private Sub cmdFirst_Click() rstCHAMCONG.MoveFirst DuaDLVaoTextBox End Sub Private Sub cmdLast_Click() rstCHAMCONG.MoveLast DuaDLVaoTextBox End Sub Private Sub cmdLuu_Click() DIM strsql As String If flag = "them" Then strsql = "INSERT INTO CHAMCONG(thangnam,manv,macv,socong,tiencong) Values ('" & txttnam.Text & "','" & txtmanv.Text & "','" & txtmacv.Text & "'," & txtsocong.Text & "," & txttiencong.Text & ")" cm.ActiveConnection = cn cm.CommandText = strsql cm.CommandType = adCmdText cm.Execute ElseIf flag = "sua" Then strsql = "UPDATE CHAMCONG SET socong=" & txtsocong.Text & ", tiencong=" & txttiencong.Text & " WHERE thangnam='" & txttnam.Text & "' and manv='" & txtmanv.Text & "' and macv='" & txtmacv.Text & "'" cm.ActiveConnection = cn cm.CommandText = strsql cm.CommandType = adCmdText cm.Execute End If CheCN Me, True KhoaDT Me, False rstCHAMCONG.Requery DuaDLVaoTextBox End Sub Private Sub cmdNext_Click() rstCHAMCONG.MoveNext DuaDLVaoTextBox End Sub Private Sub cmdPrevious_Click() rstCHAMCONG.MovePrevious DuaDLVaoTextBox End Sub Private Sub cmdSua_Click() CheCN Me, False 'txtmacv.Enabled = True dtcboDMCV.Enabled = True txtsocong.Enabled = True txttiencong.Enabled = True flag = "sua" End Sub Private Sub cmdThem_Click() KhoaDT Me, True CheCN Me, False XoaTextbox txtmacv.Enabled = False flag = "them" End Sub Private Sub cmdThoat_Click() Unload Me End Sub Private Sub cmdTim_Click() DIM gttim DIM rsttim As New ADODB.Recordset Set rsttim = rstCHAMCONG gttim = InputBox("Nhap vao thang nam can tim :", "Tim cham cong") rsttim.MoveFirst rsttim.Find "tnam='" & gttim & "'" If rsttim.EOF Then MsgBox "Khong tim thay" cmdLast_Click Else rstCHAMCONG.Bookmark = rsttim.Bookmark DuaDLVaoTextBox End If End Sub Private Sub cmdXoa_Click() DIM strsql As String strsql = "DELETE * FROM CHAMCONG WHERE thangnam='" & txttnam.Text & "'and '" & txtmanv & "' and '" & txtmacv & "'" cm.ActiveConnection = cn cm.CommandText = strsql cm.CommandType = adCmdText cm.Execute rstCHAMCONG.Requery DuaDLVaoTextBox End Sub Private Sub dtcboDMCV_Click(Area As Integer) rstDMCV.MoveFirst rstDMCV.Find " tencv ='" & dtcboDMCV.Text & "'" txtmacv.Text = rstDMCV("macv") End Sub Private Sub dtgrdCHAMCONG_RowColChange(LastRow As Variant, ByVal LastCol As Integer) DuaDLVaoTextBox End Sub Private Sub Form_Load() cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='" & App.Path & "\qlns.mdb'" cn.CursorLocation = adUseClient cn.Open rstCHAMCONG.Open "CHAMCONG", cn, adOpenStatic, adLockOptimistic, adCmdTable Set dtgrdCHAMCONG.DataSource = rstCHAMCONG rstDMCV.Open "DMCV", cn, adOpenStatic, adLockOptimistic, adCmdTable Set dtcboDMCV.RowSource = rstDMCV dtcboDMCV.ListField = "tencv" KhoaDT Me, False CheCN Me, True DuaDLVaoTextBox End Sub Sub DuaDLVaoTextBox() On Error Resume Next txttnam.Text = rstCHAMCONG(0).Value txtmanv.Text = rstCHAMCONG(1).Value txtmacv.Text = rstCHAMCONG(2).Value txtsocong.Text = rstCHAMCONG(3).Value txttiencong.Text = rstCHAMCONG(4).Value rstDMCV.MoveFirst rstDMCV.Find "Macv='" & txtmacv.Text & "'" dtcboDMCV.Text = rstDMCV.Fields(1).Value End Sub Sub XoaTextbox() txttnam.Text = "" txtmanv.Text = "" txtmacv.Text = "" txtsocong.Text = "" txttiencong.Text = "" End Sub BÀI : Chấm Công _ Command _ DataList _ DataCombo Tháng năm : Thêm Mã nv : Xóa Mã cv : Sữa Số công : Tìm Tiền công : lvwCHAMCONG Lưu Bỏ qua Thoát Option Explicit DIM cn As New ADODB.Connection DIM rstchamcong As New ADODB.Recordset DIM rstdmcv As New ADODB.Recordset DIM cm As New ADODB.Command DIM flag As String Private Sub cmdBoqua_Click() KhoaDT Me, False CheCN Me, True DuaDLVaoTextBox End Sub Private Sub cmdFirst_Click() rstchamcong.MoveFirst DuaDLVaoTextBox End Sub Private Sub cmdLast_Click() rstchamcong.MoveLast DuaDLVaoTextBox End Sub Private Sub cmdLuu_Click() DIM strsql As String If flag = "them" Then strsql = "INSERT INTO Bang(ngaythang,manv,macv,socong,tiencong) Values ('" & txtngaythang.Text & "','" & txtmanv.Text & "','" & txtmacv.Text & "'," & txtsocong.Text & "," & txttiencong.Text & ")" rstchamcong.MoveFirst rstchamcong.Find "ngaythang='" & txtngaythang.Text & "'" If Not rstchamcong.EOF Then MsgBox "Ma nv da co san Co So Du Lieu" Exit Sub End If cm.ActiveConnection = cn cm.CommandText = strsql cm.CommandType = adCmdText cm.Execute ElseIf flag = "sua" Then strsql = "UPDATE BANG SET manv='" & txtmanv.Text & "', macv='" & txtmacv.Text & "',socong=" & txtsocong.Text & ",tiencong=" & txttiencong.Text & " WHERE ngaythang='" & txtngaythang.Text & "'" cm.ActiveConnection = cn cm.CommandText = strsql cm.CommandType = adCmdText cm.Execute End If CheCN Me, True KhoaDT Me, False rstchamcong.Requery DuaDLVaoTextBox DuaDLVaoLV End Sub Private Sub cmdNext_Click() rstchamcong.MoveNext DuaDLVaoTextBox End Sub Private Sub cmdPrevious_Click() rstchamcong.MovePrevious DuaDLVaoTextBox End Sub Private Sub cmdSua_Click() CheCN Me, False 'txtmanv.Enabled = True dtcboTHELOAI.Enabled = True txtmacv.Enabled = True txtsocong.Enabled = True txttiencong.Enabled = True flag = "sua" End Sub Private Sub cmdThem_Click() KhoaDT Me, True CheCN Me, False XoaTextbox txtmanv.Enabled = False flag = "them" End Sub Private Sub cmdTim_Click() DIM gttim DIM rsttim As New ADODB.Recordset Set rsttim = rstchamcong gttim = InputBox("Nhap vao ma nv can tim :", "Tim so cong ") rsttim.MoveFirst rsttim.Find "ngaythang='" & gttim & "'" If rsttim.EOF Then MsgBox "Khong tim thay" cmdLast_Click Else rstchamcong.Bookmark = rsttim.Bookmark DuaDLVaoTextBox End If End Sub Private Sub cmdXoa_Click() DIM strsql As String strsql = "DELETE * FROM Bang WHERE ngaythang='" & txtngaythang.Text & "'" cm.ActiveConnection = cn cm.CommandText = strsql cm.CommandType = adCmdText cm.Execute rstchamcong.Requery DuaDLVaoTextBox End Sub Private Sub dtcboTHELOAI_Click(Area As Integer) rstTheLoai.MoveFirst rstTheLoai.Find "Theloai='" & dtcboTHELOAI.Text & "'" txtmanv.Text = rstTheLoai("manv") End Sub Private Sub Form_Load() cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='" & App.Path & "\qlns.mdb'" cn.CursorLocation = adUseClient cn.Open rstchamcong.Open "Bang", cn, adOpenStatic, adLockOptimistic, adCmdTable rstTheLoai.Open "TheLoai", cn, adOpenStatic, adLockOptimistic, adCmdTable Set dtcboTHELOAI.RowSource = rstTheLoai dtcboTHELOAI.ListField = "TheLoai" KhoaDT Me, False CheCN Me, True DuaDLVaoTextBox DuaDLVaoLV End Sub Sub DuaDLVaoTextBox() On Error Resume Next txtngaythang.Text = rstchamcong(0).Value txtmanv.Text = rstchamcong(1).Value txtmacv.Text = rstchamcong(2).Value txtsocong.Text = rstchamcong(3).Value txttiencong.Text = rstchamcong(4).Value rstTheLoai.MoveFirst rstTheLoai.Find "manv='" & txtmanv.Text & "'" dtcboTHELOAI.Text = rstTheLoai.Fields(1).Value End Sub Sub XoaTextbox() txtngaythang.Text = "" txtmanv.Text = "" txtmacv.Text = "" txtsocong.Text = "" txttiencong.Text = "" End Sub Sub DuaDLVaoLV() lvwchamcong.ListItems.Clear rstchamcong.MoveFirst Do While Not rstchamcong.EOF lvwchamcong.ListItems.Add , , rstchamcong(0).Value lvwchamcong.ListItems(lvwchamcong.ListItems.Count).ListSubItems.Add , , rstchamcong(1).Value lvwchamcong.ListItems(lvwchamcong.ListItems.Count).ListSubItems.Add , , rstchamcong(2).Value lvwchamcong.ListItems(lvwchamcong.ListItems.Count).ListSubItems.Add , , rstchamcong(3).Value lvwchamcong.ListItems(lvwchamcong.ListItems.Count).ListSubItems.Add , , rstchamcong(4).Value rstchamcong.MoveNext Loop rstchamcong.MoveFirst End Sub Private Sub lvwchamcong_ItemClick(ByVal Item As MSComctlLib.ListItem) rstchamcong.Move Item.Index - 1, rstchamcong.Find "ngaythang='" & Item.Text & "'" If Not rstchamcong.EOF Then txtngaythang.Text = rstchamcong(0).Value txtmanv.Text = rstchamcong(1).Value txtmacv.Text = rstchamcong(2).Value txtsocong.Text = rstchamcong(3).Value txttiencong.Text = rstchamcong(4).Value Else MsgBox "Mau tin khong co thuc" End If rstTheLoai.MoveFirst rstTheLoai.Find "manv='" & txtmanv.Text & "'" dtcboTHELOAI.Text = rstTheLoai.Fields(1).Value End Sub BÀI : Recordset Option Explicit Dim cn As New ADODB.Connection Dim rstCV As New ADODB.Recordset Private Sub cmdBoqua_Click() rstCV.CancelBatch KhoaDT Me, False CheCN Me, True cmdLast_Click End Sub Private Sub cmdFirst_Click() rstCV.MoveFirst Dichuyen Me, rstCV End Sub Private Sub cmdLast_Click() rstCV.MoveLast Dichuyen Me, rstCV End Sub Private Sub cmdLuu_Click() On Error GoTo loi rstCV.UpdateBatch KhoaDT Me, False CheCN Me, True cmdLast_Click Exit Sub loi: cmdBoqua_Click End Sub Private Sub cmdNext_Click() rstCV.MoveNext Dichuyen Me, rstCV End Sub Private Sub cmdPrevious_Click() rstCV.MovePrevious Dichuyen Me, rstCV End Sub Private Sub cmdSua_Click() On Error GoTo loi KhoaDT Me, True CheDC Me CheCN Me, False Exit Sub loi: MsgBox "Loi sua Dl" End Sub Private Sub cmdThem_Click() On Error GoTo loi rstCV.AddNew KhoaDT Me, True CheCN Me, False CheDC Me Exit Sub loi: MsgBox "Loi them dl" End Sub Private Sub cmdThoat_Click() Unload Me End Sub Private Sub cmdTim_Click() Dim gttim Dim rsttim As New ADODB.Recordset Set rsttim = rstCV gttim = InputBox("Nhap vao ma cong viec can tim :", "Tim cong viec") rsttim.MoveFirst rsttim.Find "macv='" & gttim & "'" If rsttim.EOF Then MsgBox "Khong tim thay" cmdLast_Click Else rstCV.Bookmark = rsttim.Bookmark Dichuyen Me, rstCV End If End Sub Private Sub cmdXoa_Click() On Error GoTo loi rstCV.Delete cmdLast_Click Exit Sub loi: MsgBox "Loi xoa dl" rstCV.CancelBatch cmdLast_Click End Sub Private Sub Form_Load() cn.CursorLocation = adUseClient cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\qlns.mdb" cn.Open rstCV.Open "DMCV", cn, adOpenStatic, adLockOptimistic, adCmdTable LayDL Me, rstCV KhoaDT Me, False Dichuyen Me, rstCV End Sub Private Sub Form_Unload(Cancel As Integer) If rstCV.State = adStateOpen Then rstCV.Close End If If cn.State = adStateOpen Then cn.Close End If End Sub SO DO QLNV SO DO VIDEO