Um....I'm lost please help
This isnt really VB but its VBA close enuff (and nobody in access sites has any clue)
In Access I need to create a form dynamically that shows a label for each employee in the company. What I would like to do is add code so that when the user clicks on one of those labels, it opens a different form that shows the employees schedule for a 24 hour period.
this is what i have done to create the controls.
VB Code:
Public Sub ShowSchedule()
Dim DisplayForm As Form
Dim NewControl As Control
Dim NumLocators As Integer
'for testing purposes just set it to 20 employees
NumLocators = 20
Set DisplayForm = CreateForm()
DoCmd.OpenForm DisplayForm.Name, acDesign, , , , acHidden
Dim i As Integer
For i = 1 To NumLocators
Set NewControl = CreateControl(DisplayForm.Name, acLabel)
With NewControl
.Left = 100
.Top = 500 + i * 250
.Width = 1000
.Height = 200
.Caption = "WhoCaresForNow"
End With
Set NewControl = Nothing
Next i
Dim FormName As String
FormName = DisplayForm.Name
DoCmd.Save acForm, DisplayForm.Name
DoCmd.Close acForm, DisplayForm.Name
DoCmd.OpenForm FormName
Set NewControl = Nothing
Set DisplayForm = Nothing
End Sub
This all works fine. But....
My quesiton is....How do you set the OnClick event property code during runtime. For example I would like to make it so that if you click "Joe Schmoe" on the employee list it calls a sub called ShowEmployeeSchedule() passing his employeeID along with it.
Remember I have to set this in runtime NOT design time.
Thanx in advance
Clint