assigning functions to events through code

J

Jesper F

I'm trying to assign function names such as "=Calculate
()", "=Modify()" etc. to the event properties of certain
controls in a form. This needs to be done through code. I
have a large number of forms where the event properties
are altered from time to time and I'm building a toolbox
to make it easier for myself.

Right now I have this working:
Dim sFunctionname
sFunctionname = "=Calculate()"
Docmd.openform "formname", acDesign
Forms!formname.Form(controlname).OnEnter = sFunctionName

However if I try to name the event with a variable I can't
get it to work:
Dim sEvent
sEvent = "OnEnter"
Forms!formname.Form(controlname).sEvent = sFunctionName

and I'm getting a "property not allowed" error.

Do any of you know which syntax to use here?
Thanks for any help.
 
B

Brian

Jesper F said:
I'm trying to assign function names such as "=Calculate
()", "=Modify()" etc. to the event properties of certain
controls in a form. This needs to be done through code. I
have a large number of forms where the event properties
are altered from time to time and I'm building a toolbox
to make it easier for myself.

Right now I have this working:
Dim sFunctionname
sFunctionname = "=Calculate()"
Docmd.openform "formname", acDesign
Forms!formname.Form(controlname).OnEnter = sFunctionName

However if I try to name the event with a variable I can't
get it to work:
Dim sEvent
sEvent = "OnEnter"
Forms!formname.Form(controlname).sEvent = sFunctionName

and I'm getting a "property not allowed" error.

Do any of you know which syntax to use here?
Thanks for any help.

forms!formname(controlname).properties(sEvent) = sFunctionName
 
J

Jesper F

forms!formname(controlname).properties(sEvent) =
sFunctionName

Just what I needed. Thanks!
 

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