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:
  1. Public Sub ShowSchedule()
  2.     Dim DisplayForm As Form
  3.     Dim NewControl As Control
  4.     Dim NumLocators As Integer
  5.    
  6.     'for testing purposes just set it to 20 employees
  7.     NumLocators = 20
  8.    
  9.     Set DisplayForm = CreateForm()
  10.     DoCmd.OpenForm DisplayForm.Name, acDesign, , , , acHidden
  11.    
  12.     Dim i As Integer
  13.     For i = 1 To NumLocators
  14.         Set NewControl = CreateControl(DisplayForm.Name, acLabel)
  15.         With NewControl
  16.             .Left = 100
  17.             .Top = 500 + i * 250
  18.             .Width = 1000
  19.             .Height = 200
  20.             .Caption = "WhoCaresForNow"
  21.         End With
  22.         Set NewControl = Nothing
  23.     Next i
  24.    
  25.     Dim FormName As String
  26.     FormName = DisplayForm.Name
  27.     DoCmd.Save acForm, DisplayForm.Name
  28.     DoCmd.Close acForm, DisplayForm.Name
  29.    
  30.     DoCmd.OpenForm FormName
  31.    
  32.     Set NewControl = Nothing
  33.     Set DisplayForm = Nothing
  34. 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