0
當我點擊按鈕command9
我想使用計數功能來統計有多少記錄匹配combo7
和Insp_Cat = 1
,然後計算總記錄的20%。然後使用Update
語句將字段Insp_Type
更新爲「C」,將記錄數限制爲先前計算的總記錄數的20%。Microsoft Access VBA填充總記錄百分比的字段
這是我的日期代碼,但得到計數線上的語法錯誤。
Private Sub Command9_Click()
Dim strSql As String
Dim Rec_Qty As Integer
Dim Rec_Perc As Integer
'Return record count for all records in Tbl_Inspections matching WO_ID in Combo7 and Insp_Cat =1
Rec_Qty = Count (WO_ID & Insp_Cat) Where [WO_ID]= Me.[Combo7]& [Insp_Cat]=1 From Tbl_Inspections
Rec_Per = Rec_Qty * 0.2
'Update records for "C" 20% records using Rec_Per value in limit function of Update command
strSql = "Update Tbl_Inspections"
strSql = strSql & "Set Insp_Type = 'C' WHERE WO_ID = Me.Combo7 & Insp_Cat = 1 & Limit = Rec_Per"
CurrentDb.Execute strSql
End Sub
任何人都可以幫忙嗎?
是在* Rec_Qty *線的僞代碼?因爲它在VBA中不兼容。另外,在更新查詢中的'Set'之前需要一個空格。 – Parfait