我需要一些帮助。当我运行以下查询时,如果我包含其中的Pkg编号部分,我将得不到任何结果。当我在Access中运行查询时,它工作正常。 变种的例子 包裹号码1_282 Rptdt 201301
Dim db As Database 'generic database object
Dim rst As Recordset 'this is going to hold the query result
Set db = CurrentDb
Dim PKG As Double
Dim rptDT As Double
Dim wireDT As Date
Set rst = db.OpenRecordset("SELECT Max(tbl_Revision.Revision_Number) as Revision_Number FROM tbl_Revision" & _
" where (tbl_Revision.RUN_YR_MO=" & rptDT & ")" & _
" and (tbl_Revision.Package_Number=" & PKG & ")")
getRevision = rst!Revision_Number + 1
答案 0 :(得分:3)
如果你想要1_282工作,PKG不能是双倍的。所以把它变成一个字符串。 此外,您还必须添加引号:
" where (tbl_Revision.RUN_YR_MO='" & rptDT & "')" & _