Office中国论坛/Access中国论坛

标题: [求助]类型不匹配 [打印本页]

作者: iloveuxm    时间: 2006-9-26 23:36
标题: [求助]类型不匹配
2个表的复制,表字段不同,我写了代码,现在告诉我类型不匹配请问这是为什么

Dim db As Databases
Dim sql As String
Dim rs As Recordset
Dim db1 As Databases
Dim sql1 As String
Dim rs1 As Recordset

Set db = CurrentDb()
sql = "SELECT * FROM 资产 "
Set rs = rs.OpenRecordset(sql, dbOpenDynaset)

Set db1 = CurrentDb()
sql1 = "SELECT * FROM 产品 "
Set rs1 = rs1.OpenRecordset(sql, dbOpenDynaset)


If Me.类别.Value = "资产" Then


rs1.AddNew
rs1.Fields("产品名称") = rs.Fields("设备名称")
rs1.Fields("产品编号") = rs.Fields("设备编号")
rs1.Fields("产品型号") = rs.Fields("设备型号")
rs1.Fields("参考价格") = rs.Fields("设备原值")
rs1.Fields("启用时间") = rs.Fields("启用时间")
rs1.Fields("沧暗氐?quot;) = rs.Fields("安装地点")
rs1.Fields("产品性质") = rs.Fields("资产性质")
rs1.Fields("类别") = rs.Fields("类别")
rs1.Fields("所属部门") = rs.Fields("所属部门")
rs1.Fields("保修年限") = rs.Fields("保修年限")
rs1.Fields("资产所属部门") = rs.Fields("资产所属部门")

rs1.Update
rs.Update
End If[attach]20578[/attach]


[此贴子已经被作者于2006-9-26 16:25:37编辑过]


作者: fan0217    时间: 2006-9-26 23:58
把例子放上来更容易解决问题
作者: iloveuxm    时间: 2006-9-27 00:17
附件已经上传请高手指点下
作者: iloveuxm    时间: 2006-9-27 00:27
刚才没传好,呵呵,现在已经传上了~~~请各位大侠指教
作者: iloveuxm    时间: 2006-9-27 18:14
大家帮帮忙啊,在线等~~~~~~~
作者: fan0217    时间: 2006-9-27 23:32
对比一下错误在哪里,红色的是你的原代码,在后面还有错误,那就自己试着更改了,错误提示找不到项目。

Dim db As Database   'Dim db As Databases
Dim sql As String
Dim rs As Recordset
Dim db1 As Database  'Dim db As Databases
Dim sql1 As String
Dim rs1 As Recordset

Set db = CurrentDb()
sql = "SELECT 资产.* FROM 资产 "
Set rs = db.OpenRecordset(sql, dbOpenDynaset)  'Set rs = rs.OpenRecordset(sql, dbOpenDynaset)

Set db1 = CurrentDb()
sql1 = "SELECT 产品.* FROM 产品 "
Set rs1 = db1.OpenRecordset(sql, dbOpenDynaset)  'Set rs1 = rs1.OpenRecordset(sql, dbOpenDynaset)
作者: iloveuxm    时间: 2006-9-29 17:00
谢谢版主的指教~~~~
作者: iloveuxm    时间: 2006-10-8 21:27
回家改了几天,还是没有改出来,请各位指点下.谢谢了~~
作者: iloveuxm    时间: 2006-10-9 21:15
请各位高手帮帮忙啊~~~~




欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) Powered by Discuz! X3.3