Private Sub Form1_Load()
Adodc1.Visible = False
Command4.AddItem "客户名称"
Command4.AddItem "收款金额"
Command4.AddItem "凭证"
Command4.AddItem "录入日期"
End Sub
Private Sub Command1_Click()
If Command1.Caption = "确定 " Then
Adodc1.Refresh
Adodc1.Recordset.MoveLast
Command5.Enabled = True
Command3.Enabled = True
Command4.Enabled = True
Command2.Enabled = True
Command1.Caption = "添加记录"
Else
Adodc1.Recordset.AddNew
Command1.Caption = "确定"
Command5.Enabled = False
Command3.Enabled = False
Command2.Enabled = False
Command4.Enabled = False
End If
End Sub
Private Sub Command2_Click()
Dim i As Integer
i = MsgBox("删除记录吗?", vbYesNo, "警告")
If i = 6 Then
Adodc1.Recordset.Delete
Adodc1.Refresh
End If
End Sub
Private Sub Command3_Click()
Adodc1.Recordset.MovePrevious
Command5.Enabled = True
If Adodc1.Recordset.BOF Then
Adodc1.Recordset.MoveFirst
Command1.Enabled = False
End If
End Sub
Private Sub Command4_Click()
If TxtFind.Text = "" Then
MsgBox "输入要查询的内容!", 48, "提示"
Exit Sub
End If
If Adodc1.Recordset Then
MsgBox "记录不存在", 64, "提示"
End If
End Sub
Private Sub Command5_Click()
Adodc1.Recordset.MoveNext
Command1.Enabled = True
If Adodc1.Recordset.EOF Then
Adodc1.Recordset.MoveLast
Command5.Enabled = False
End If
End Sub
一下是我的程序中的控件
datagrid1
adodc1
label1~4
text1~4 和txtfind
command1~5
combo1
我的程序运行之后在datagrid1中添加记录总是弹出关键字不能为空Null 如果我的问题没有描述清楚请告诉我。。。。
|