Can I Programmatically assign event and event content?

  • Thread starter Thread starter Kan D.
  • Start date Start date
K

Kan D.

Can an event AND event content be assigned prorammatically to a control?

See below example's ".OnClick" line...

Dim c_imgStatus As Image

With c_imgStatus
.Name = "imgStatus" & i
.Picture = "\\path\path\Status Button.jpg"
.HyperlinkSubAddress = "Form FormName"
.OnClick = "MyVariable = " my_OtherVariable & Chr(13) & _
"msgBox MyVariable"
End With

So when I click on the button, I want the click to execute the button's "On
Click" event that I'm trying to programmtically assign...

Thank you for your help,

Kan
 
One possible way is to mimic dot-Net, that is, in the event that fires "your
interest", call all the "procedures" (with Eval or CallBack) that are
stored into a given collection:

- Create a collection
- Append, in the collection, the (text of the) procedure(s) to be called
(can be done programmatically, can add or remove items (would be procedures)
as it fit your needs, at run time)
- In the event, have fixed code that cycles through each of the elements in
the collection and which Eval it, or CallBack it.


Hoping it may help,
Vanderghast, Access MVP
 
Back
Top