chnage this line [VBA]a = CABIN[/VBA] to [VBA]a = "CABIN"[/VBA]
chnage this line [VBA]a = CABIN[/VBA] to [VBA]a = "CABIN"[/VBA]
Tommy, you are the man. Just changed all the outputs to " " around the name and they all show up thanks a lot a lot.
LOL see post #13
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.
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.Originally Posted by zizou
NOTE: The tab indexes must be in the correct order.
Look at input mask and/or format. NOTE: Once the text is formated any manipulations will need to consider the formatingOriginally Posted by zizou
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.
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).
What is KeyAscii and ch(13). Where do I find those?
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]
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.
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.
Works like a charm. Once again, you are the man Tommy