VB6 Data控件操作为什么运行不了呢?
Option ExplicitPrivate Sub Command1_Click()
Data1.Recordset.MoveFirst
Command2.Enabled = False
End Sub
Private Sub Command2_Click()
Data1.Recordset.MovePrevious
Command1.Enabled = True
Command3.Enabled = True
If Data1.Recordest.BOF Then
Data1.Recordset.MoveFirst
Command1.Enabled = False
Else
Command1.Enabled = True
End If
End Sub
Private Sub Command3_Click()
Data1.Recordset.MoveNext
Command1.Enabled = True
Command2.Enabled = True
If Data1.Recordset.BOF Then
Data1.Recordset.MoveLast
Command4.Enabled = False
Else
Command1.Enabled = True
End If
End Sub
Private Sub Command4_Click()
Data1.Recordset.MoveLast
Command3.Enabled = False
End Sub
Private Sub Command5_Click()
If Combo1.ListIndex = -1 Then
MsgBox "请选择查询的项目", vbOKOnly, "系统提示"
Combo1.SetFocus
Exit Sub
End If
If Len(Text4.Text) = 0 Then
MsgBox "请输入查询的内容", vbOKOnly, "系统提示"
Text4.SetFocus
Exit Sub
End If
If Combo1.ListIndex = 0 Then
Data1.Recordset.FindFirst "Name=" & "'" & Text4.Text & "'"
ElseIf Combo1.ListIndex = 1 Then
Data1.Recordset.FindFirst "Tel=" & "'" & Text4.Text & "'"
Else
Data1.Recordset.FindFirst "Email=" & "'" & Text4.Text & "'"
End If
If Data1.Recordset.NoMatch Then
MsgBox "记录不存在", vbOKOnly, "系统提示"
End If
End Sub
Private Sub Commamd6_Click()
If MsgBox("是否删除记录,确定吗?", vbQuestion Or vbYesNo, "警告") = 6 Then
Data1.Recordset.Delete
Data1.Refresh
End If
End Sub
Private Sub Command7_Click()
If Command7.Caption = "添加" Then
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Command7.Caption = "保存"
Else
If Len(Text1.Text) = 0 Then
MsgBox "姓名不能为空!", vbOKOnly, "系统提示"
Text1.SetFocus
Exit Sub
End If
If Len(Text2.Text) = 0 Then
MsgBox "电话不能为空!", vbOKOnly, "系统提示"
Text2.SetFocus
Exit Sub
End If
If Len(Text3.Text) = 0 Then
MsgBox "电子邮件不能为空!", vbOKOnly, "系统提示"
Text1.SetFocus
Exit Sub
End If
Data1.Recordset.AddNew
MsgBox "添加记录成功!", vbOKOnly, "系统提示"
Command7.Caption = "添加"
End If
End Sub
Private Sub Form_Load()
Combo1.AddItem "姓名"
Combo1.AddItem "电话"
Combo1.AddItem "电子邮件"
Data1.Visible = False
End Sub
如题,请各位大虾指教!!!!!!!!!!! --------------------编程问答-------------------- 天书,看不懂 --------------------编程问答-------------------- 1 数据库连接在哪里
2 Private Sub Command3_Click()
Data1.Recordset.MoveNext
Command1.Enabled = True
Command2.Enabled = True
If Data1.Recordset.BOF(改为EOF) Then
Data1.Recordset.MoveLast
Command4.Enabled = False
Else
Command1.Enabled = True
End If
End Sub
补充:VB , 数据库(包含打印,安装,报表)