B
Bunster147
I am using outlook 2007 (Latest version) with BCM and developing a small for
a home business that I run.
I am trying to create a form which shows a varying number of product items
on it and I need to handle the events of these product rows, e.g. when
clicked, show the products details.
As the number of lines on the report varies I am programmatically creating
the controls on the form using the visual basic software which comes with
Microsoft office 2007.
The version of VB shows as “Microsoft Visual Basic 6.5†on the “About
Microsoft Visual Basic†Help screen.
This is part of the code used to generate the controls.
Please note that the form has already been created in Project with no
controls. The following code is just test code I am using to test the event
handling problem.
Private Sub UserForm_Initialize()
Dim mycmd As Control
Dim strControl As String
strControl = "Forms.Label.1"
Set mycmd = TestScreen.Controls.Add(strControl)
mycmd.Left = 5
mycmd.Top = 5
mycmd.Width = 70
mycmd.Height = 12
mycmd.BackColor = vbRed
mycmd.TextAlign = 3
mycmd.Caption = "Test Label"
mycmd.Visible = True
mycmd.ForeColor = vbBlack
mycmd.Name = "TEST"
End Sub
On inspection of the code when debugging, the names of the controls (All
Labels) are Label1, Label2 etc.
My idea was that I would have a generic event handler to handle the events
for those controls that I need events for.
But here is the problem I have encountered.
Initially I inserted the code
Private Sub TEST_click()
MsgBox ("clicked")
End Sub
But no events were picked up on the new control.
I was thinking of adding a generic event handler but thought if the events
are not being generated then this would not help either.
All I need to know is how to have the created controls react to events.
a home business that I run.
I am trying to create a form which shows a varying number of product items
on it and I need to handle the events of these product rows, e.g. when
clicked, show the products details.
As the number of lines on the report varies I am programmatically creating
the controls on the form using the visual basic software which comes with
Microsoft office 2007.
The version of VB shows as “Microsoft Visual Basic 6.5†on the “About
Microsoft Visual Basic†Help screen.
This is part of the code used to generate the controls.
Please note that the form has already been created in Project with no
controls. The following code is just test code I am using to test the event
handling problem.
Private Sub UserForm_Initialize()
Dim mycmd As Control
Dim strControl As String
strControl = "Forms.Label.1"
Set mycmd = TestScreen.Controls.Add(strControl)
mycmd.Left = 5
mycmd.Top = 5
mycmd.Width = 70
mycmd.Height = 12
mycmd.BackColor = vbRed
mycmd.TextAlign = 3
mycmd.Caption = "Test Label"
mycmd.Visible = True
mycmd.ForeColor = vbBlack
mycmd.Name = "TEST"
End Sub
On inspection of the code when debugging, the names of the controls (All
Labels) are Label1, Label2 etc.
My idea was that I would have a generic event handler to handle the events
for those controls that I need events for.
But here is the problem I have encountered.
Initially I inserted the code
Private Sub TEST_click()
MsgBox ("clicked")
End Sub
But no events were picked up on the new control.
I was thinking of adding a generic event handler but thought if the events
are not being generated then this would not help either.
All I need to know is how to have the created controls react to events.