爲什麼在添加where語句時以下msaccess vba語句失敗? 我要檢查,如果字段值where msaccess vba
Set rsMySet = CurrentDb.OpenRecordset("PivotTblInvDepts")
'Start the count at the position number of the first column-oriented field
'Remember that Recordsets start at 0
For i = 3 To rsMySet.Fields.Count - 1
'*********************************************************************************************************************
'Use the recordset field.name property to build out the SQL string for the current field
strSQL = "INSERT INTO TabularDepts ([Depts], [Code], [Description], [Qty])" & _
"SELECT" & "'" & rsMySet.Fields(i).Name & "'" & " AS Dept," & _
"[PivotTblInvDepts].[Code],[PivotTblInvDepts].[Description]," & _
"[" & rsMySet.Fields(i).Name & "]" & _
"FROM PivotTblInvDepts;" & _
"WHERE" & " (rsMySet.Fields(i).Name)>0"
爲什麼要調用VBA記錄集中的同一個表並在插入查詢中使用它,尤其是在循環訪問列名而不是實際記錄?考慮創建一個附加爲存儲查詢對象,並用'DoCmd.OpenQuery'調用它。 – Parfait