VBA to set value and tab off of text box

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bbatson
    New Member
    • Sep 2007
    • 46

    VBA to set value and tab off of text box

    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!
  • mshmyob
    Recognized Expert Contributor
    • Jan 2008
    • 903

    #2
    Try

    [CODE=vb]
    Me.textbox.SetF ocus
    Me.textbox.Valu e = "7"
    SendKeys "{TAB}", True
    [/CODE]

    Originally posted by bbatson
    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!

    Comment

    • missinglinq
      Recognized Expert Specialist
      • Nov 2006
      • 3533

      #3
      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.Set Focus

      Linq ;0)>

      Comment

      • mshmyob
        Recognized Expert Contributor
        • Jan 2008
        • 903

        #4
        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).

        Originally posted by missinglinq
        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.Set Focus

        Linq ;0)>

        Comment

        Working...