Userform textbox behaviour
Userform textbox behaviour
Userform textbox behaviour
Userform textbox behaviour
Userform textbox behaviour
Userform textbox behaviour Userform textbox behaviour Userform textbox behaviour Userform textbox behaviour Userform textbox behaviour Userform textbox behaviour Userform textbox behaviour Userform textbox behaviour
Userform textbox behaviour Userform textbox behaviour
Userform textbox behaviour
Go Back  Xtreme Visual Basic Talk > > > > Userform textbox behaviour


Reply
 
Thread Tools Display Modes
  #1  
Old 10-23-2017, 04:16 AM
Daigon Ali Daigon Ali is offline
Regular
 
Join Date: Aug 2014
Location: London
Posts: 59
Default Userform textbox behaviour


I have a userform which contains a textbox. Users scan numbers into this box which is then searched for on the worksheet by code.
If a match is found various columns on the found row are populated.

The scanners automatically finish with Enter or Tab, so for best efficiency I wanted to add code to initiate the search straight after scanning away based on these keystrokes.
I implemented this by detecting chars 13 or 9 in the KeyUp event of the textbox.

The problem is that this works for a while but then the textbox becomes unresponsive to these keystrokes and pressing Tab actually enters a tab within the textbox.
I've tried both KeyUp & KeyDown events, modal/non-modal forms, search code in a separate sub, but nothing seems to prevent this from happening and there doesn't seem to be an explanation for it.
Reply With Quote
  #2  
Old 10-23-2017, 07:16 AM
MPiUserform textbox behaviour MPi is offline
Senior Contributor

Forum Leader
* Expert *
 
Join Date: Dec 2001
Location: Quebec
Posts: 1,000
Default

Try putting a DoEvents in your search procedure to give the hand to the system.
__________________
MPi²
Reply With Quote
  #3  
Old 10-25-2017, 03:12 AM
Daigon Ali Daigon Ali is offline
Regular
 
Join Date: Aug 2014
Location: London
Posts: 59
Default

I do have DoEvents in the code, but the code has actually finished executing when this behaviour occurs.

I've found pretty much the same issue described here https://stackoverflow.com/questions/...ting-to-next-c
Reply With Quote
  #4  
Old 10-26-2017, 03:19 AM
Daigon Ali Daigon Ali is offline
Regular
 
Join Date: Aug 2014
Location: London
Posts: 59
Default

I got round this issue by replacing the label (the only other control on the form) I had with another textbox with its locked property set to True so it can be accessed but not edited.
I then put the search code in the Exit event of the search textbox instead of the KeyUp event.
Exiting then enters the locked textbox which contains code in the Enter event to set the focus back to the main textbox.
Reply With Quote
  #5  
Old 10-26-2017, 10:39 AM
MPiUserform textbox behaviour MPi is offline
Senior Contributor

Forum Leader
* Expert *
 
Join Date: Dec 2001
Location: Quebec
Posts: 1,000
Default

Good solution.

It could also be a button with the "Default" property to True so it gets the focus on Enter key -> CommandButton1_Click()
or Tab using CommandButton1_Enter()

And the control can be put outside the visible area of the Userform.
__________________
MPi²
Reply With Quote
Reply

Tags
textbox, tab, code, search, keyup, found, userform, keystrokes, enters, pressing, unresponsive, event, forms, happening, explanation, prevent, keydown, events, modal/non-modal, separate, match, worksheet, columns, populated, row


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Userform textbox behaviour
Userform textbox behaviour
Userform textbox behaviour Userform textbox behaviour
Userform textbox behaviour
Userform textbox behaviour
Userform textbox behaviour Userform textbox behaviour Userform textbox behaviour Userform textbox behaviour Userform textbox behaviour Userform textbox behaviour Userform textbox behaviour
Userform textbox behaviour
Userform textbox behaviour
 
Userform textbox behaviour
Userform textbox behaviour
 
-->