0
我已經編寫了代碼並在Access 2007上運行它,但我不希望顯示答案但它不顯示。我認爲有一個我遺漏的代碼,請幫助展示。在VBA中顯示結果的代碼
代碼是:
Private Sub cmdCalculate_Click()
On Error GoTo ErrorHandling
Dim rsAsset As Recordset
Dim SQL As String
SQL = "SELECT * FROM Asset WHERE Asset.Asset_Condition ='Repairs';"
Set rsAsset = CurrentDb.OpenRecordset(SQL)
Dim Total As Integer
Total = 0
rsAsset.MoveFirst
While (Not rsAsset.EOF)
Total = Total + rsAsset!Asset_Condition
rsAsset.MoveNext
Wend
Dim Ave As Double
Ave = Total/rsAsset.RecordCount
Debug.Print "Total Repairs= " & Total
Exit Sub
ErrorHandling:
MsgBox Err.Description
rsAsset.Close
End Sub
我已經充滿了數據的表,但不知道怎麼寫,將顯示的答案代碼。