求教:
用兰版主提供的范例我开始学习SQL。首先谢谢兰版主。
在范例中我根据需要做了改动。当在《修改》和《删除》模块中,如下这句出错:
'RS1.FindFirst "编号='" & TextBox编号1.Value & "'"
系统提示:“标准表达式中数据类型不匹配”
应如何改动?请帮助!谢谢!
《修改》模块全文如下:
Private Sub CommandButton10_Click() '修改
'On Error GoTo 100
If TextBox编号1.Text = "" Then
MsgBox "编号不允许空白,请重新查询。", 1 + 16, "系统提示": Exit Sub
TextBox编号1.SetFocus
Else
Dim RS1 As Recordset
Dim DB1 As Database
Set DB1 = OpenDatabase(ThisWorkbook.Path & "\" & "学生档案.MDB")
Set RS1 = DB1.OpenRecordset(Name:="客户表01", Type:=dbOpenDynaset)
'===如下这句出错,编号字段就是自动编号的ID字段===
RS1.FindFirst "编号='" & TextBox编号1.Value & "'"
If Me.CommandButton8.Visible Then
For i = 1 To recNo - 2
RS1.FindNext "编号='" & TextBox编号1.Value & "'"
Next
End If
RS1.Edit
RS1.Fields("发动机号").Value = TextBox机号1.Value
RS1.Fields("姓名").Value = TextBox姓名1.Value
RS1.Fields("电话").Value = TextBox电话1.Value
RS1.Fields("移动电话").Value = TextBox移动1.Value
RS1.Fields("车架号").Value = TextBox车架1.Value
RS1.Fields("变速箱号").Value = TextBox变速箱1.Value
RS1.Fields("卡号").Value = TextBox卡号1.Value
RS1.Fields("卡别").Value = TextBox卡别1.Value
RS1.Fields("购卡日期").Value = Format(TextBox购卡日1.Value, "yyyy-mm-dd")
RS1.Fields("购车日期").Value = Format(TextBox购车日1.Value, "yyyy-mm-dd")
RS1.Fields("地址").Value = TextBox地址1.Value
RS1.Fields("身份证号").Value = TextBox身份1.Value
RS1.Fields("保单号").Value = TextBox保单1.Value
RS1.Fields("首保日期").Value = Format(TextBox首保日1.Value, "yyyy-mm-dd")
RS1.Fields("续保日期").Value = Format(TextBox续保日1.Value, "yyyy-mm-dd")
RS1.Fields("型号").Value = TextBox型号1.Value
RS1.Fields("牌号").Value = TextBox牌号1.Value
RS1.Fields("颜色").Value = TextBox颜色1.Value
RS1.Fields("生产日期").Value = Format(TextBox生产日1.Value, "yyyy-mm-dd")
RS1.Fields("地区").Value = TextBox地区1.Value
RS1.Fields("邮编").Value = TextBox邮编1.Value
RS1.Fields("工作单位").Value = TextBox工作单位1.Value
RS1.Fields("类别").Value = TextBox类别1.Value
RS1.Fields("分部").Value = TextBox分部1.Value
RS1.Update
RS1.Close
Set RS1 = Nothing
Set DB1 = Nothing
End If
dbfX7tvz.rar
(112.06 KB, 下载次数: 82)
[此贴子已经被作者于2005-4-5 13:08:37编辑过] |