我正在使用 Access 2013 并且有一個報告,當它打開時我試圖設定八個未系結文本框的值。在我到目前為止撰寫的代碼中,我打開了一個記錄集并用它來計算八個專案的值。這部分代碼作業正常。現在我想將這八個值放入報告中,用于計算。
報告中第一個未系結的文本框名稱是“CivPistonUnder”
這是代碼:
Dim strDocName As String
Dim lngPistonUnder As Long
strDocName = "rptAWMP"
DoCmd.OpenReport strDocName, acViewPreview, , , acWindowNormal
'this is where I want to set the value of the unbound textbox
'I have tried
Me.CivPistonUnder = lngPistonUnder
'I get a compilation error: Method or data member not found
'I tried
Set CivPistonUnder = lngPistonUnder
'I get Compile error: Object required
'I tried
Set Report.rptAWMP!CivPistonUnder = lngPistonUnder
'I get Object Required
有沒有辦法將此資訊傳遞給報告?
uj5u.com熱心網友回復:
在列印預覽中打開報表后,您將無法操作報表上的資料。它模擬列印,發送到列印機后您也無法更改任何內容。:)
您必須在報告事件中執行此操作,例如Report_Load。
Private Sub Report_Load()
' This will work
Me.txtUnbound.Value = "Hello World!"
End Sub
要將值傳遞給事件程序,您可以使用 TempVars,或公共陣列/集合。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/433072.html
標籤:vba 毫秒访问 报告 ms-access-2013
上一篇:如何使用觸發器復制記錄?
