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'行嗎? –
是的,我不知道它會返回多少行,但我有它將從我返回的行數,所以我試圖獲得每行的第一個字段值,如果這會返回感。 –