AMTSelect是声明的变量变型为GetRows的阵列错误尝试从各行拉头字段值
Rcount时是整数
我试图从每一行拉头字段值但我不断收到一个错误,说下标超出范围。错误发生在for循环中。
代码如下:
If Contractnum <> "" Then
CNTRecords = "Select Count(*) from [Manual_AINs] WHERE [Manual_AINs].[Contract_Number]= '" & Contractnum & "';"
Set rs = CurrentDb.OpenRecordset(CNTRecords)
rCount = rs.Fields(0)
Set rs = Nothing
If rCount > 1 Then
qAMT = "Select [Dollar Amount] from [Manual_AINs] WHERE ((([Manual_AINs].[Contract_Number])='" & Contractnum & "'));"
Set rs = CurrentDb.OpenRecordset(qAMT)
AMTSelect = rs.GetRows
AMTSelectString = "Choose appropriate dollar amount of AIN from the selection below:" & Chr(10) & Chr(10)
For i = 1 To rCount
AMTSelectString = AMTSelectString & i & ".) " & Format(AMTSelect(0, (i - 1)), "$#,##0.00") & Chr(10)
Next i
它在For循环中。从AMTSelectstring开始是的,我认为它的一些被删除,当我复制它,但AMTSelect是一个变量。本质上AMTSelect = rs.GetRows –
你能解释最后一行中的AMTSelect(0,(i-1))吗?你想访问数组“AMTSelect”中的'i-1'行吗? –
是的,我不知道它会返回多少行,但我有它将从我返回的行数,所以我试图获得每行的第一个字段值,如果这会返回感。 –