为什么在添加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