1 Private Sub cmdAdd_Click() 2 res = MsgBox("确定要添加这条记录吗?", vbYesNo + vbQuestion, "添加记录") 3 If res = vbYes Then 4 myres.AddNew 5 myres.Fields("1") = TextBox11.Value 6 myres.Fields("2") = TextBox22.Value 7 myres.Fields("3") = TextBox33.Value 8 myres.Fields("4") = ComboBox1.Value 9 myres.Fields("5") = ComboBox2.Value 10 myres.Fields("6") = ComboBox3.Value 11 myres.Update 12 TextBox44.Value = "共有 " & myres.RecordCount & " 條記錄!" 13 ElseIf res = vbNo Then 14 If myres.BOF = True And myres.EOF = True Then 15 Exit Sub 16 Else 17 myres.MoveFirst 18 Call display 19 End If 20 End If 21 End Sub 22 23 24 Private Sub cmdDel_Click() 25 res = MsgBox("确定要刪除这条记录吗?", vbYesNo + vbQuestion, "刪除记录") 26 If res = vbYes Then 27 myres.Delete 28 If myres.EOF = True Then Exit Sub 29 myres.MoveNext 30 myres.Update 31 Call display 32 TextBox44.Value = "共有 " & myres.RecordCount & " 條記錄!" 33 ElseIf res = vbNo Then 34 If myres.BOF = True And myres.EOF = True Then 35 Exit Sub 36 Else 37 myres.MoveFirst 38 Call display 39 End If 40 End If 41 End Sub 42 43 Private Sub cmdUpdate_Click() 44 res = MsgBox("确定要修改这条记录吗?", vbYesNo + vbQuestion, "修改记录") 45 If res = vbYes Then 46 myres.Fields("1") = TextBox11.Value 47 myres.Fields("2") = TextBox22.Value 48 myres.Fields("3") = TextBox33.Value 49 myres.Fields("4") = ComboBox1.Value 50 myres.Fields("5") = ComboBox2.Value 51 myres.Fields("6") = ComboBox3.Value 52 myres.Update 53 TextBox44.Value = "共有 " & myres.RecordCount & " 條記錄!" 54 ElseIf res = vbNo Then 55 If myres.BOF = True And myres.EOF = True Then 56 Exit Sub 57 Else 58 myres.MoveFirst 59 Call display 60 End If 61 End If 62 End Sub