Keeping Focus

Tsango

Registered User.
Local time
Today, 23:07
Joined
Mar 31, 2006
Messages
64
How can I allow a user to enter some text in a Textbox

React to that text in the Afterupdate, or Lost Focus Event and then clear the text and keep the focus in the Textbox ready for the next input?

Only not reacting to the text when the input is "" or NULL


I have the following but it does not work because you can not Setfocus within it's own Afterupdate or Lostfocus event.

Private Sub txtBarCode_AfterUpdate()
If txtBarCode.Value <> "" And Not IsNull(txtBarCode.Value) Then​
If FindBarCode(txtBarCode.Value) Then​
Call AddProductToBasket​
Else​
MsgBox "No Barcode Available For This Product", vbOKOnly, "Scan Item Error"​
End If​
txtBarCode.Value = ""​
txtBarCode.SetFocus​
End If​
End Sub
 
Last edited:
How about setting the focus back to the textbox from the gotfocus event of the next field?
 
I first set the focus to some other control, then set it to the one you want.

Larry
 
Those suggestions do not work because they cause an error:

"Cannot move focus to <control>"

I solved the problem by creating two text boxes and the focus cycles between the two.
 

Users who are viewing this thread

Back
Top Bottom