标题: rst.open "select * from XXXXX WHERE ID=a "....是否不能用条件变量 [打印本页] 作者: DABEN 时间: 2008-12-21 11:20 标题: rst.open "select * from XXXXX WHERE ID=a "....是否不能用条件变量 [:30] 求助:请问a是变量时,在执行中提示“至少一个参数没有被指定值”,可用其他什么方法解决?谢谢!
Dim Conn As New ADODB.Connection
Dim rst As New ADODB.Recordset
Dim rst1 As New ADODB.Recordset
Dim i, ii, i1, ii1 As Integer
Dim a As String
a = Forms!XXXX!ID
Set Conn = CurrentProject.Connection
rst1.Open "select * from XXXX WHERE ID=a ", Conn, adOpenDynamic, adLockOptimistic作者: tz-chf 时间: 2008-12-21 11:23
变量拿引号外面去
a是文本?作者: DABEN 时间: 2008-12-21 11:26
谢谢!TZ-CHF
A是文本作者: DABEN 时间: 2008-12-21 11:32
原帖由 tz-chf 于 2008-12-21 11:23 发表
变量拿引号外面去
a是文本?
老大:如何拿到引号外面?谢作者: Henry D. Sy 时间: 2008-12-21 11:40
dim strSQL as string
strSQL="select * from XXXX WHERE ID='"& a & "'"
rst1.Open strSQL, Conn, adOpenDynamic, adLockOptimistic作者: DABEN 时间: 2008-12-21 11:49
谢版主!
[ 本帖最后由 DABEN 于 2008-12-21 11:58 编辑 ]作者: DABEN 时间: 2008-12-21 13:02 标题: 整理给大家,谢谢版主。 Dim Conn As New ADODB.Connection
Dim rst1 As New ADODB.Recordset
Dim strSQL as string
Dim a As String
Dim b As Single
a = Forms!XXXX!ID '属字符
b = Forms!XXXX!gz '属数值
Set Conn = CurrentProject.Connection
strSQL="select * from XXXX WHERE ID='" & a & "' And gz=" & b & ""
rst1.Open strSQL, Conn, adOpenDynamic, adLockOptimistic