Consulting

Page 2 of 2 FirstFirst 1 2
Results 21 to 32 of 32

Thread: If Statements With Mutiple Inputs And Multiple Outputs

  1. #21
    Moderator VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    chnage this line [VBA]a = CABIN[/VBA] to [VBA]a = "CABIN"[/VBA]

  2. #22
    VBAX Regular
    Joined
    Jun 2008
    Location
    tulsa, OK
    Posts
    24
    Location
    Tommy, you are the man. Just changed all the outputs to " " around the name and they all show up thanks a lot a lot.

  3. #23
    Moderator VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    LOL see post #13

  4. #24
    VBAX Regular
    Joined
    Jun 2008
    Location
    tulsa, OK
    Posts
    24
    Location
    Tommy,
    I was also wondering how to do two other things in my form. After I input a number into each text box I want the cursur to go directly to the next text box, instead of pressing tab or clicking in the box to type into it. Also when I directly go to the next input textbox I need the numbers to be formatted. Ex. instead of 12000, I would want 12,000. How can I insert this into my currect code. Thanks again.

  5. #25
    Moderator VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    Quote Originally Posted by zizou
    Tommy,
    I was also wondering how to do two other things in my form. After I input a number into each text box I want the cursur to go directly to the next text box, instead of pressing tab or clicking in the box to type into it.
    How do you know when you are finished typing? If the number is of a certain length ex 12000 it is doable just remember to enter that many numbers, otherwise you will need to tab or pick to change textboxes.
    NOTE: The tab indexes must be in the correct order.
    Quote Originally Posted by zizou
    Also when I directly go to the next input textbox I need the numbers to be formatted. Ex. instead of 12000, I would want 12,000. How can I insert this into my currect code. Thanks again.
    Look at input mask and/or format. NOTE: Once the text is formated any manipulations will need to consider the formating

  6. #26
    VBAX Regular
    Joined
    Jun 2008
    Location
    tulsa, OK
    Posts
    24
    Location
    You would press enter or something like that. And when you would do that, it would format the number, with a comma and then go to the next textbox.

  7. #27
    Moderator VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    I don't have VB handy so....

    Set the KeyAscii to true on the form level (when it loads help file tells you how) and in the keydown event check for chr(13) if it is true then
    [VBA]

    textbox.text = Format(textbox.text,"##,###")
    sendkeys "{tab}"

    [/VBA]I will post the correct code tonight when I get home. You could try till then to code it, use F1 a lot (I do).

  8. #28
    VBAX Regular
    Joined
    Jun 2008
    Location
    tulsa, OK
    Posts
    24
    Location
    What is KeyAscii and ch(13). Where do I find those?

  9. #29
    Moderator VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    This will trap the return key and move the cursor to the next item in the tab order line.
    [VBA]Private Sub Form_Load()
    KeyPreview = True
    end sub
    Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = vbKeyReturn Then
    KeyCode= 0
    SendKeys "{TAB}"
    End If
    End Sub[/VBA]

  10. #30
    VBAX Regular
    Joined
    Jun 2008
    Location
    tulsa, OK
    Posts
    24
    Location
    Thanks Tommy. I was thinking about a way to figure out the formatting issue. I was thinking something along the lines of- If format of cell is #####, then format cell to ##,### after hitting the return key. What do you think. I do not know the code to do this though.

  11. #31
    Moderator VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    in the textbox_lostfocus event..

    [VBA]
    sub text1_lostfocus
    text1.text = FixNum(text1.text)
    end sub

    Function FixNum(iStr As String) As String
    FixNum = Format(iStr, "##,###")
    End Function
    [/VBA]

    the fixnum function is tested. I am pretty sure that it is the lostfocus event but I could be wrong on that one. Pick the drop down on the upper right hand side and look for it, in VBA it is Exit but in VB I think it is lostfocus.

  12. #32
    VBAX Regular
    Joined
    Jun 2008
    Location
    tulsa, OK
    Posts
    24
    Location
    Works like a charm. Once again, you are the man Tommy

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •