Adding a Text Box at Run Time

R

Richard Spaull

I tried posting the following to microsoft.public.vb.controls and was
instructed to try a VBA newsgroup. I tried
microsoft.public.word.vba.userforms but no joy. Can anyone advise as to the
best newsgroup for this sort of question and/or help with this particular
problem.


Using VB 6.3 within Word, I want to add a TextBox control to a UserForm at
run time from within a class module and then handle an AfterUpdate event (or
similar).

I've declared :-

Private WithEvents LocalTextBox As TextBox

and then added the control as follows :-

Public Sub AddToForm(Form As UserForm)
Set LocalTextBox = Form.Controls.Add("Forms.TextBox.1")
.....

I can then handle certain events (such as the Change event) but an
AfterUpdate event (or similar) is not available.

Where I am going wrong ?
 
T

TC

I don't know UserForms, so take this FWIW: are you sure that a textbox
in a userform /does have/ an afterupdate event? Afterupdate sounds more
like an msaccess control event ...

HTH,
TC
 
R

Richard Spaull

If you add a TextBox normally to a UserForm in design mode (or whatever it's
called) in Word, then an AfterUpdate event is available. It occurs "after
data in a control is changed through the user interface". However, there
doen't seem to be any such event for the control I'm adding at run time via

Set LocalTextBox = Form.Controls.Add("Forms.TextBox.1").

Maybe I'm adding a different sort of TextBox - I don't know enough about it
to be sure.
 
T

TC

Sorry, I don't know anything about userforms so I can not help you
there.

Good luck,
TC
 

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