
VB+Access设计图书管理系统(11) |
以下为窗体的代码: Private Sub Command1_Click() On Error GoTo adderr Text1.SetFocus Adodc1.Recordset.AddNew Exit Sub adderr: MsgBox Err.Description End Sub Private Sub Command2_Click() On Error GoTo deleteerr With Adodc1.Recordset If Not .EOF And Not .BOF Then If MsgBox("删除当前记录吗?", vbYesNo + vbQuestion) = vbYes Then .Delete .MoveNext If .EOF Then .MoveLast End If End If End With Exit Sub deleteerr: MsgBox Err.Description End Sub Private Sub Command3_Click() Adodc1.Recordset.MovePrevious If Adodc1.Recordset.BOF Then MsgBox "这是第一条记录", vbOKCancel + vbQuestion Adodc1.Recordset.MoveFirst End If End Sub Private Sub Command4_Click() Adodc1.Recordset.MoveNext If Adodc1.Recordset.EOF Then MsgBox "这是最后一条记录", vbOKCancel + vbQuestion Adodc1.Recordset.MoveLast End If End Sub Private Sub Command5_Click() If Adodc1.Recordset.EOF Then MsgBox "记录空", vbOKCancel + vbQuestion End Else Adodc1.Recordset.MoveFirst End If Exit Sub End Sub Private Sub Command6_Click() If Adodc1.Recordset.RecordCount = 0 Then MsgBox "空记录", vbOKCancel + vbQuestion End Else Adodc1.Recordset.MoveLast End If End Sub Private Sub Command7_Click() MDIForm1.Show frmtousu.Hide End Sub 到这里,各个窗体的界面和代码都介绍完了。发布后可以作为一个实际的项目应用。 |