Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Putting Focus into Textbox
I have a userform that I am using a barcode scanner to populate a text box. When the form loads the cursor is in the barcode textbox. On change event it does some stuff unloads the form and then runs the macro that loads the form. When it reloads the Cancel button is the active control. Every time that the form loads I want the cursor on the barcode text box. How do I make this happen? It is at the top of the tab order.
Thanks, Jay |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Putting Focus into Textbox
I should have included the initialize code.
Private Sub UserForm_Initialize() Dim ErrorCodes(1 To 7, 1 To 2) As String Def.ColumnCount = 2 ErrorCodes(1, 1) = "1" ErrorCodes(2, 1) = "2" ErrorCodes(3, 1) = "3" ErrorCodes(4, 1) = "4" ErrorCodes(5, 1) = "5" ErrorCodes(6, 1) = "6" ErrorCodes(7, 1) = "7" ErrorCodes(1, 2) = "Print Moving/Orientation" ErrorCodes(2, 2) = "Damaged Rolls/Sheets/Splices" ErrorCodes(3, 2) = "Bad Material Envelopes/Inserts" ErrorCodes(4, 2) = "Setups" ErrorCodes(5, 2) = "Press Malfunction" ErrorCodes(6, 2) = "Missing pieces for validation" ErrorCodes(7, 2) = "Unknown/Other" If Me.RangeTF = False Then Me.BarCode2.Visible = False End If If Range("Q2") < "" Then Me.Mach = Range("Q2") Me.Def = Range("Q3") Me.OPID = Range("Q4") Else Me.Mach = "???" Me.Def = 7 Me.OPID = "???" End If Def.List = ErrorCodes End Sub |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Putting Focus into Textbox
hi Jay,
have you try: Private Sub UserForm_Initialize() Me.TextBox1.SetFocus End Sub isabelle Le 2016-06-16 Ã* 18:15, jlclyde a écrit : I have a userform that I am using a barcode scanner to populate a text box. When the form loads the cursor is in the barcode textbox. On change event it does some stuff unloads the form and then runs the macro that loads the form. When it reloads the Cancel button is the active control. Every time that the form loads I want the cursor on the barcode text box. How do I make this happen? It is at the top of the tab order. Thanks, Jay |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Putting Focus into Textbox
or,
Me.Controls("MyTextBox").SetFocus isabelle Le 2016-06-16 Ã* 21:07, isabelle a écrit : hi Jay, have you try: Private Sub UserForm_Initialize() Me.TextBox1.SetFocus End Sub isabelle Le 2016-06-16 Ã* 18:15, jlclyde a écrit : I have a userform that I am using a barcode scanner to populate a text box. When the form loads the cursor is in the barcode textbox. On change event it does some stuff unloads the form and then runs the macro that loads the form. When it reloads the Cancel button is the active control. Every time that the form loads I want the cursor on the barcode text box. How do I make this happen? It is at the top of the tab order. Thanks, Jay |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Putting Focus into Textbox
I have
|
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Putting Focus into Textbox
This too.
|
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Putting Focus into Textbox
I have a userform that I am using a barcode scanner to populate a
text box. When the form loads the cursor is in the barcode textbox. On change event it does some stuff unloads the form and then runs the macro that loads the form. When it reloads the Cancel button is the active control. Every time that the form loads I want the cursor on the barcode text box. How do I make this happen? It is at the top of the tab order. Thanks, Jay Perhaps have a look at the SelStart and SelLength properties... -- Garry Free usenet access at http://www.eternal-september.org Classic VB Users Regroup! comp.lang.basic.visual.misc microsoft.public.vb.general.discussion --- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus |
#8
Posted to microsoft.public.excel.programming
|
|||
|
|||
Putting Focus into Textbox
Garry,
I thought this was going to work.... I finally see what it is doing, just not sure how to fix this. When the scanner reads the barcode it populates the textbox and fires a Enter command. So if there is a message box, the enter is used to get rid of the message box. If there is no message box then it enters in the field and essentially goes to the next control. Is there a way to turn off enter? Thanks, Jay |
#9
Posted to microsoft.public.excel.programming
|
|||
|
|||
Putting Focus into Textbox
Garry,
I thought this was going to work.... I finally see what it is doing, just not sure how to fix this. When the scanner reads the barcode it populates the textbox and fires a Enter command. So if there is a message box, the enter is used to get rid of the message box. If there is no message box then it enters in the field and essentially goes to the next control. Is there a way to turn off enter? Thanks, Jay Set the barcode scanner action to use the 'Tab' key instead of the (default) 'Enter' key. (The 'Enter' is set as default action because most often the scanner is used to populate cells directly) -- Garry Free usenet access at http://www.eternal-september.org Classic VB Users Regroup! comp.lang.basic.visual.misc microsoft.public.vb.general.discussion --- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus |
#10
Posted to microsoft.public.excel.programming
|
|||
|
|||
Putting Focus into Textbox
Garry,
I could not change the scanner to enter as they are used in other programs for all sorts of things. Instead, I used message boxes to capture the fact that a enter was being thrown out. It is not pretty, but it is working. Thanks for the help. Jay |
#11
Posted to microsoft.public.excel.programming
|
|||
|
|||
Putting Focus into Textbox
On 6/17/2016 7:40 AM, jlclyde wrote:
Garry, I could not change the scanner to enter as they are used in other programs for all sorts of things. Instead, I used message boxes to capture the fact that a enter was being thrown out. It is not pretty, but it is working. Thanks for the help. Jay How about using FindWindow to see if the window is open or not, then send the appropriate text? http://stackoverflow.com/questions/2...a-partial-name |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Putting Cell contents into a TextBox? | Excel Programming | |||
TextBox focus 4 | Excel Programming | |||
putting validation to TextBox in the userform | Excel Programming | |||
putting validation to TextBox in the userform | Excel Programming | |||
Which textbox have focus? | Excel Programming |