Visual Basic Delete DELETE FROM WHERE Validate Validate
Visual Basic 程序设计教程
⑷ Delete语句 语法: DELETE FROM 表名 WHERE 条件;
⑵ Validate事件 Validate事 件 与 Reposition事 件 不 同 , 是 当 某 一 记 录 成 为 当 前 记 录 之 前 , 或 是 在 Update、 Delete、Unload或Close操作之前触发。 语法: Private Sub Data 1_Validate (action As Integer , save As Integer)
⑥输入如下所示的程序代码。 Private Sub Add. Cmd_Click() '添加新记录 Data 1. Recordset. Add. New Data 1. Recordset. Update Data 1. Recordset. Move. Last txt. Pro. Name. Set. Focus End Sub Private Sub Data 1_Reposition() Lbl. Record. Num. Caption = Data 1. Recordset. Absolute. Position + 1 End Sub
Private Sub Data 1_Validate(Action As Integer, Save As Integer) '确定是否修改,如不修改则 恢复为原先的内容 Dim Dia If Save = True Then Dia = Msg. Box("您确定要添加/修改该记录吗?", vb. Information + vb. Yes. No, "确定修改") If Dia = vb. No Then Save = False Data 1. Update. Controls End If End Sub
Private Sub Del. Cmd_Click() Dim Dia = Msg. Box("您确定要删除吗?", vb. Information + vb. Yes. No, "删除记录") If Dia = vb. Yes Then '如果当前无记录,则弹出对话框告知用户 If Data 1. Recordset. EOF Then Msg. Box "no record" Exit Sub End If Data 1. Recordset. Delete Data 1. Recordset. Move. Next
If Data 1. Recordset. EOF Then Msg. Box "这是最后一条记录!", vb. Exclamation + vb. OKOnly, "最后一条记录" End If Else Exit Sub End If End Sub
Private Sub Edit. Cmd_Click() '修改记录 Data 1. Recordset. Edit Data 1. Recordset. Update End Sub Private Sub Exit. Cmd_Click() End Sub Private Sub Form_Load() Data 1. Caption = Data 1. Record. Source End Sub
Private Sub Txt. Adr_Key. Press(Key. Ascii As Integer) If Key. Ascii = 13 Then Txt. Phone. Set. Focus End Sub Private Sub Txt. City_Key. Press(Key. Ascii As Integer) If Key. Ascii = 13 Then Txt. Adr. Set. Focus End Sub Private Sub Txt. Name_Key. Press(Key. Ascii As Integer) If Key. Ascii = 13 Then Txt. City. Set. Focus End Sub
Private Sub Txt. Phone_Key. Press(Key. Ascii As Integer) If Key. Ascii = 13 Then Txt. Fax. Set. Focus End Sub Private Sub txt. Pro. Name_Key. Press(Key. Ascii As Integer) If Key. Ascii = 13 Then Txt. Name. Set. Focus End Sub
- Slides: 60