access不匹配的问题
我用access数据库,ID列是自动编号
但在程序里用它作为条件时,提示不匹配
Private Sub Command1_Click()
Dim strSql2 As String
Dim A As Long
Dim rs As New ADODB.Recordset
Dim Q As Integer
Q = Text16.Text
strSql2 = "select * from 表 where ID ='" & Q & "' "
QueryExt (strSql2)
Adodc1.ConnectionString = Conn
Adodc1.RecordSource = strSql2
Adodc1.Refresh
Set rs = QueryExt(strSql2)
If rs.RecordCount < 0 Then
A = MsgBox("你确实要修改这条记录", vbYesNo)
If A = vbYes Then
Set DataGrid1.DataSource = Adodc1
If Text3.Text <> "" Then
rs.Fields("合计") = Text3.Text
Else
rs.Fields("合计交税") = 0
End If
rs.Update
Adodc1.Refresh
End If
End If
End Sub
这where ID= X
X是一个直接的整数时,程序能运行,
但rs.recordcount > 0 这句且没有能找到的行
但<0 就能找到指定X的行
请教了
[解决办法]
Q = Text16.Text
改为:Q=val(tim(Text16.Text))试一下