Swtiching the focus of Textboxes
I am programming a VBA form to accept the UPC number generated by a scanner and update values accordingly with a database. My main problem is with the user form I'm trying to create. I want to program a Change or After_Update event on the textbox that accepts the UPC code from the scanner to do the following:
place the number in the text box, then reselect that textbox and select the text within the textbox.
The scanner is very plug-and-play and pops UPC numbers whereever a cursor is. I want the user to just have to click the scanner on a UPC code and the existing text will be replaced, thus initiating the Change or After_Update event.
My problem is, I cant get the focus to return to the box AND select all the text within the box so its ready to be replaced. Just one of those roadblocks thta stopping me and I can't figure out what methods Excel VBA affords to me to get that cursor back in the text and select it.
Also, of note, you can't record macros within forms in Excel. So, i can't just record my actions and get an answer. I need a tried and tested result here.
|