|
附件中有两个实例:一个是流水编码字段为数字型,操作没有问题。另外一个是把流水编码字段为修改为文本型后操作报错,提示“标准表达式中数据类型不匹配”,代码如下:
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim rs As New ADODB.Recordset
Dim strSql As String
strSql = "select * from 物品管理_采购单临时表 where 流水编码=" & Me.流水编码 & " and 采购临时ID<" & Me.采购临时ID & ""
rs.Open strSql, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
Do While Not rs.EOF
If Me.物品编码 = rs!物品编码 Then
If Me.采购单价 = rs!采购单价 Then
Me.采购数量 = Me.采购数量 + rs!采购数量
rs.Delete
Exit Do
End If
End If
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
End Sub
报错代码行为
rs.Open strSql, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
请问如何解决,谢谢。 |
|