472,122 Members | 1,517 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,122 software developers and data experts.

VBA-excel,text box-enter event

hello i need help in this please. i dont have much knowledge of VBA but can do very basic things by learning from different forums.

i want to create one excel application where there will be few userforms. and on each there will be some text boxes.

i want it to work like this.
if user puts number 2 in textbox1 on userform1 and then PRESS ENTER, unload userform1 and show userform2, but if user puts 3 in textbox1 on userform1 and PRESS ENTER then unload userform1 and show userform3 and so on.......... pressing enter is very important event.

i have tried it with click event and it is working but it needs to be enter event.

thanks a lot.
ronak
Jan 23 '09 #1
4 13902
MikeTheBike
639 Expert 512MB
Hi

Have you tried the 'TextBox1_AfterUpdate' Event !?

MTB
Jan 23 '09 #2
thanks for your reply

have tried the afterupdate event in the textbox, but that event is fired only if the form is closed by the user, it doesnt work with pressing enter key.

the code i tried was
Private Sub TextBox1_AfterUpdate()
If TextBox1.Text = "2" Then UserForm2.Show
If TextBox1.Text = "3" Then UserForm3.Show
End Sub

may be i dont know how to write the code, can you please help me with the code so that after putting 2 and pressing the enter key the userform1 will close and userform2 will show............and so on with 3, 4, 5.........till 10.

i have previously tried with userform1_click event like below.but it doesnt unload userform1 at the same time.

Private Sub UserForm_Click()
If TextBox1.Text = "2" Then UserForm2.Show
If TextBox1.Text = "3" Then UserForm3.Show
End Sub

thanks
Jan 27 '09 #3
MikeTheBike
639 Expert 512MB
Hi again

I do not know why your code does not work but this
Expand|Select|Wrap|Line Numbers
  1. Private Sub TextBox1_AfterUpdate()
  2.     If TextBox1.Text = "2" Then UserForm2.Show
  3.     If TextBox1.Text = "3" Then UserForm3.Show
  4. End Sub
works OK on my PC (running Excel 2k3).

Perhaps some else can shed some light on this. I don't know if there are any setting in Excel/VBA to disable control event.

Do any of the forms or contols events work ??


MTB
Jan 28 '09 #4
Thanks a bunch MikeTheBike that solved a problem I had as well
Nov 10 '10 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by andreas | last post: by
1 post views Thread by Igor Mendizabal | last post: by
3 posts views Thread by DKJ | last post: by
22 posts views Thread by Illya Havsiyevych | last post: by
1 post views Thread by Igor Mendizabal | last post: by
18 posts views Thread by Ann Scharpf via AccessMonster.com | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.