I am stuck with a Event Procedure Issue. I have created one Dynamic report in MS access using VBA. For the same I have created some dynamic controls like lables, Textbox, buttons, etc. I am able to create report successfully. The only issue is that I don't know how to create "Onclick" Event procedure for Dynamically created button. Every Time I click on that button it gives me an errors which says " No such Event found" kind off.
Here is My Code...
Here is My Code...
Code:
Private Sub btn_createReport() Dim btnNew As Access.CommandButton Dim rpt As Report ' hold report object cmdSelect = "select * from xyz;" Set rpt = CreateReport ' set properties of the Report With rpt .Width = 12500 .RecordSource = cmdSelect .Caption = title End With Set btnNew = CreateReportControl(rpt.Name, acCommandButton, acPageHeader, , , 7000, 50, 1500, 400) btnNew.Caption = "Back" btnNew.Name = "btnNew" ' btnNew.OnClick = "[btn_Click]" 'lblNew.FontUnderline = True lblNew.SizeToFit End Sub Private Sub btnNew_Click() DoCmd.OpenForm Form1, acNormal, , , , acWindowNormal MsgBox "Hello" End Sub
Comment