Set/Assign an Event to textbox from Code
I am creating text boxes on a form programatically. This allows me to name all the controls how I want them named from vba, avoiding the 'one at a time' method, and also lets me rebuild the form entirely from scratch in an instant.
My question is once I have created an individual textbox and assigned properties as follows ....
Set ctlText = CreateControl(frm.Name, acTextBox, acFooter, "", "", _
intPositionX, intPositionY, AmtTextWidth, AllTextHeight)
ctlText.Name = "TotalPallets"
ctlText.BackColor = 65280
[u]Can I add then </u>assign either a macro or the function to the textbox as the next line of code, as follows (except this doesn't seem to work)
ctlText.AfterUpdate = "=GetProductAmounts()"
which assigns the function directly, or...
ctlText.AfterUpdate = "GetOrderTotal"
which assigns the macro. If I do the latter manually in the properties AfterUpdate Event it does work, so I know the macro is working. But when I attempt to set it from code the event property doesn't get filled. What am I doing wrong?
|