Can I Programmatically assign event and event content?

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
 
M

Michel Walsh

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top