| 发表于:2008-01-11 23:14:44 楼主 |
请问各位老手!我刚开始入门学习vb +access编程,在编写到一个程序中出现以下错误! 先给代码: dim rs as new adodb.recordset dim sql as string dim x as integer dim rs1 as new adodb.recordset dim sql1 as string if option1.value = true then sql = "select * from 销售记录表 where 流水单号 = '" & listinput & "'" 'listinput是text控件 rs.open sql, db, adopenkeyset, adlockoptimistic sql1 = "select 商品名称 from 商品资料表 where 商品编号 = '" & rs.fields("商品编号") & "'" rs1.open sql1, db, adopenkeyset, adlockoptimistic for x = 1 to rs.recordcount with viewlist .textmatrix(x, 0) = rs.fields("流水单号") .textmatrix(x, 1) = rs.fields("销售日期") .textmatrix(x, 2) = rs.fields("商品编号") .textmatrix(x, 3) = rs1.fields("商品名称") .textmatrix(x, 4) = rs.fields("销售数量") .textmatrix(x, 5) = rs.fields("销售单价") .textmatrix(x, 6) = rs.fields("金额小计") end with rs.movenext viewlist.rows = viewlist.rows + 1 next x rs.close else end if if option2.value = true then sql = "select * from 销售记录表 where 销售日期 = '" & cdate(startdate) & "'" 'startdate也是text控件,但值由monthview控件提供! rs.open sql, db, adopenkeyset, adlockoptimistic sql1 = "select 商品名称 from 商品资料表 where 商品编号 = '" & rs.fields("商品编号") & "'" rs1.open sql1, db, adopenkeyset, adlockoptimistic for x = 1 to rs.recordcount with newlist .textmatrix(x, 0) = rs.fields("流水单号") .textmatrix(x, 1) = rs.fields("销售日期") .textmatrix(x, 2) = rs.fields("商品编号") .textmatrix(x, 3) = rs1.fields("商品名称") .textmatrix(x, 4) = rs.fields("销售数量") .textmatrix(x, 5) = rs.fields("销售单价") .textmatrix(x, 6) = rs.fields("金额小计") end with rs.movenext next x rs.close else end if option1的程序部分完全没有问题,调试过了 可当调试到option2的程序部分时,卡在了红字部分,提示“标准表达式中数据类型不匹配!” 我数据库中的销售日期字段设定的是时间/日期类型。 不知道我的程序错在那里了!希望各位老手帮我看看!!新手20积分,聊表谢意! |
|
|
|
|