我用VB编写了个程序,但是文本框不能显示数据库内容,着急呀!请高手看看缺少了什么。先谢谢了!!
文本框不能显示数据库内容,是哪里错了呀,我是新手还请大家多多帮忙,下面我把代码发过来,PrivateSubCommand1_Click()'添加信息控件单击代码'IfCo...
文本框不能显示数据库内容,是哪里错了呀,我是新手还请大家多多帮忙,下面我把代码发过来,
Private Sub Command1_Click() '添加信息控件单击代码'
If Command1.Caption = "确定" Then
Data1.UpdateRecord
'将数据更新到记录'
Data1.Recordset.MoveLast
Command2.Enabled = True
Command3.Enabled = True
Command4.Enabled = True
Command5.Enabled = True
Command1.Caption = "添加信息"
Else
Data1.Recordset.AddNew
Command1.Caption = "确定"
Command2.Enabled = False
Command3.Enabled = False
Command4.Enabled = False
Command5.Enabled = False
End If
End Sub
Private Sub Command2_Click()
Dim i As Integer
i = MsgBox("你确认删除记录")
If i = 是 Then
Data1.Recordset.Delete
Data1.Refresh
End If
End Sub
Private Sub Command3_Click() '上一页控件单击代码'
Data1.Recordset.MovePrevious
Command4.Enabled = True
If Data1.Recordset.BOF Then
Data1.Recordset.MoveFirst
Command3.Enabled = False
End If
End Sub
Private Sub Command4_Click() '下一页控件单击代码'
Data1.Recordset.MoveNext
Command3.Enabled = True
If Data1.Recordset.EOF Then
Data1.Recordset.MoveLast
Command4.Enabled = False
End If
End Sub
Private Sub Command5_Click() '查询设备控件单击代码'
If Text6.Text = "" Then
MsgBox "请选择查询项并出入查询内容"
Exit Sub
End If
Data1.Recordset.FindFirst Combo1.Text & "=" & "" & Text6.Text & ""
If Data1.Recordset.NoMatch Then
MsgBox "记录不存在"
End If
End Sub
Private Sub Form_Load() '窗口加载'
Data1.Visible = False
Combo1.AddItem "设备地址码"
Combo1.AddItem "设备类型"
Combo1.AddItem "所在楼座"
Combo1.AddItem "所在楼层"
Combo1.AddItem "详细注释"
End Sub 展开
Private Sub Command1_Click() '添加信息控件单击代码'
If Command1.Caption = "确定" Then
Data1.UpdateRecord
'将数据更新到记录'
Data1.Recordset.MoveLast
Command2.Enabled = True
Command3.Enabled = True
Command4.Enabled = True
Command5.Enabled = True
Command1.Caption = "添加信息"
Else
Data1.Recordset.AddNew
Command1.Caption = "确定"
Command2.Enabled = False
Command3.Enabled = False
Command4.Enabled = False
Command5.Enabled = False
End If
End Sub
Private Sub Command2_Click()
Dim i As Integer
i = MsgBox("你确认删除记录")
If i = 是 Then
Data1.Recordset.Delete
Data1.Refresh
End If
End Sub
Private Sub Command3_Click() '上一页控件单击代码'
Data1.Recordset.MovePrevious
Command4.Enabled = True
If Data1.Recordset.BOF Then
Data1.Recordset.MoveFirst
Command3.Enabled = False
End If
End Sub
Private Sub Command4_Click() '下一页控件单击代码'
Data1.Recordset.MoveNext
Command3.Enabled = True
If Data1.Recordset.EOF Then
Data1.Recordset.MoveLast
Command4.Enabled = False
End If
End Sub
Private Sub Command5_Click() '查询设备控件单击代码'
If Text6.Text = "" Then
MsgBox "请选择查询项并出入查询内容"
Exit Sub
End If
Data1.Recordset.FindFirst Combo1.Text & "=" & "" & Text6.Text & ""
If Data1.Recordset.NoMatch Then
MsgBox "记录不存在"
End If
End Sub
Private Sub Form_Load() '窗口加载'
Data1.Visible = False
Combo1.AddItem "设备地址码"
Combo1.AddItem "设备类型"
Combo1.AddItem "所在楼座"
Combo1.AddItem "所在楼层"
Combo1.AddItem "详细注释"
End Sub 展开
2个回答
展开全部
这一段好象有点问题
Private Sub Command5_Click() '查询设备控件单击代码'
If Text6.Text = "" Then
MsgBox "请选择查询项并出入查询内容"
Exit Sub
End If
Data1.Recordset.FindFirst
Combo1.Text = "" & Text6.Text & ""
If Data1.Recordset.NoMatch Then
MsgBox "记录不存在"
End If
End Sub
你这样试试呢?
Private Sub Command5_Click() '查询设备控件单击代码'
If Text6.Text = "" Then
MsgBox "请选择查询项并出入查询内容"
Exit Sub
End If
Data1.Recordset.FindFirst
Combo1.Text = "" & Text6.Text & ""
If Data1.Recordset.NoMatch Then
MsgBox "记录不存在"
End If
End Sub
你这样试试呢?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询