看看下面的VB数据库data控件好像是basename属性出错

来源:百度知道 编辑:UC知道 时间:2024/06/22 20:21:27
Private Sub comadd_Click()
If comadd.Caption = "确定" Then
On Error GoTo errorhandler
Data1.UpdateRecord
Data1.Recordset.MoveLast
comprev.Enabled = True
comnext.Enabled = True
comdel.Enabled = True
comfind.Enabled = True
comadd.Caption = "添加"
Else
Data1.Recordset.AddNew
comadd.Caption = "确定"
comprev.enable = False
comnext.Enabled = False
comdel.Enabled = False
comfind.Enabled = False
End If
Exit Sub
errorhandler:
If Err.Number = 524 Then
MsgBox "该记录已存在!", 48, "警告"
End If
Resume
End Sub

Private Sub comdel_Click()
Dim i As Integer
i = MsgBox("真的要删除当前记录吗?", 52, "警告")
If i = 6 Then
Data1.Recordset.Delete
Data1.Refresh
End If
End Sub

Private Sub comfind_Click()
If textfind = "" Then
MsgBox "请输入查询内容!", 48, "提示"<

1.应该使用DatabaseName这个属性
2.用data控件必须使用access97格式,所以要在access里将目标文件保存成97格式,或者用vb自带的“可视化数据管理器”进行创建access文件。
3.个人意见:不推荐使用data控件,也不推荐使用控件,比较喜欢代码。