|
-
Dec 12th, 2006, 06:37 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] textbox question?
Hi,
I have 10 textboxes in the form and would like to do something when the user press ENTER, it go to the next textbox (like the tab key does). (Multi-line) text box is not the option.
THanks!
-
Dec 12th, 2006, 06:47 AM
#2
Re: textbox question?
you can use either textboxName.SetFocus or use the following code
VB Code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
SendKeys vbTab
End If
End Sub
Set FormName.KeyPreview = True in design mode. It will navigate based on the TabIndex value
If an answer to your question has been helpful, then please, Rate it!
Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.
-
Dec 12th, 2006, 06:52 AM
#3
Re: textbox question?
This is fundamentally what ganeshmoorthy has, but I prefer using the KeyPress event.
VB Code:
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then ' Enter = Tab
SendKeys "{tab}"
KeyAscii = 0
End If
End Sub
-
Dec 12th, 2006, 06:56 AM
#4
Re: textbox question?
 Originally Posted by Hack
This is fundamentally what ganeshmoorthy has, but I prefer using the KeyPress event.
I agree, but I suggest writting it in the Form_KeyPress instead of Text1_KeyPress. If he uses text1_KeyPress then he has to write it in every textbox, if he does not have control array...
If an answer to your question has been helpful, then please, Rate it!
Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.
-
Dec 12th, 2006, 06:58 AM
#5
Thread Starter
Hyperactive Member
Re: textbox question?
 Originally Posted by ganeshmoorthy
you can use either textboxName.SetFocus or use the following code
VB Code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
SendKeys vbTab
End If
End Sub
Set FormName.KeyPreview = True in design mode. It will navigate based on the TabIndex value
Hi,
I tried on both form keypress, keydown events, but not working.
Any reason why?
-
Dec 12th, 2006, 07:00 AM
#6
Re: textbox question?
have you set the KeyPreview of the Form as I mentioned in my earlier post
If an answer to your question has been helpful, then please, Rate it!
Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.
-
Dec 12th, 2006, 07:02 AM
#7
Re: textbox question?
Again, a matter of preference. If I'm naviagting a specific set of individual controls I prefer coding those individual controls rather than turning "control" over to the form itself.
In the project I just finished one screen is an Audited Financial Statement log. It has three sections: Statement of Operations, Balance Sheet and Cash Flow. Between those three sections there are 61 textboxs (including two separate comments textboxs) and I coded each of their KeyPress events for the Enter key. It may be a bit more work, but I like the control I have of what textbox does what when.
-
Dec 12th, 2006, 07:09 AM
#8
Thread Starter
Hyperactive Member
Re: textbox question?
 Originally Posted by mapperkids
Hi,
I tried on both form keypress, keydown events, but not working.
Any reason why?
If KeyAscii = 13 Then ' Enter = Tab
SendKeys "{tab}"
KeyAscii = 0
End If
Yes, it works on the text1.keypress event, but NOT work on form.keypress event.
Thanks a lot !
-
Dec 12th, 2006, 07:11 AM
#9
Re: [RESOLVED] textbox question?
ya, you may be right for certain projects, but I prefer coding in the Form which has got more controls, eventhough two controls have to be excluded
VB Code:
If KeyCode = 13 Then
If Not (Form1.ActiveControl.Name = "Text1" Or Form1.ActiveControl.Name = "Text2") Then
SendKeys vbTab
End If
End If
 Originally Posted by Mapperkids
Yes, it works on the text1.keypress event, but NOT work on form.keypress event.
have you set the Form's KeyPreview property to True...
If an answer to your question has been helpful, then please, Rate it!
Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|