Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 99
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 99
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Putting Focus into Textbox

I have



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Putting Focus into Textbox

This too.
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,182
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,182
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 86
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Putting Cell contents into a TextBox? PEno1 Excel Programming 2 December 3rd 04 04:31 AM
TextBox focus 4 Tim Coddington Excel Programming 6 August 4th 04 03:51 AM
putting validation to TextBox in the userform salihyil[_6_] Excel Programming 1 February 26th 04 01:10 PM
putting validation to TextBox in the userform salihyil[_8_] Excel Programming 1 February 26th 04 11:59 AM
Which textbox have focus? Tom Ogilvy Excel Programming 0 August 27th 03 03:12 PM


All times are GMT +1. The time now is 04:25 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"