By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,607 Members | 1,817 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,607 IT Pros & Developers. It's quick & easy.

VBA to set value and tab off of text box

P: 46
Hello,

Suppose I had a text box, call it "textbox". What would be the code to set the value of this textbox to a certain number, say 7, and then tab off of the text box onto the next item in the tab order?

Thank you!
Feb 21 '08 #1
Share this Question
Share on Google+
3 Replies


mshmyob
Expert 100+
P: 904
Try

Expand|Select|Wrap|Line Numbers
  1. Me.textbox.SetFocus
  2. Me.textbox.Value = "7"
  3. SendKeys "{TAB}", True
  4.  
Hello,

Suppose I had a text box, call it "textbox". What would be the code to set the value of this textbox to a certain number, say 7, and then tab off of the text box onto the next item in the tab order?

Thank you!
Feb 21 '08 #2

missinglinq
Expert 2.5K+
P: 3,532
SendKeys is a bad idea and should be avoided unless nothing else will work! It's unpredictable and can cause strange things with NumLock! Why not simply set the focus to the next textbox in line? Instead of

SendKeys "(Tab)", True

try

NextTextBox.SetFocus

Linq ;0)>
Feb 21 '08 #3

mshmyob
Expert 100+
P: 904
I agree Linq but he wanted to TAB. I just assumed by his request he didn't know what his next control would be (lol).

SendKeys is a bad idea and should be avoided unless nothing else will work! It's unpredictable and can cause strange things with NumLock! Why not simply set the focus to the next textbox in line? Instead of

SendKeys "(Tab)", True

try

NextTextBox.SetFocus

Linq ;0)>
Feb 21 '08 #4

Post your reply

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