Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

a really tough one - userforms

  Asked By: Diane    Date: Nov 30    Category: MS Office    Views: 704
  

Its a userform to do item information lookups.
The user keys in the product code (UPC), VBA searched for that record
in the worksheet "master", and then returns the item's description and
price in the userform.

More demonstration purposes, I have only 1 item in the master list.

So open it up, and in the UPC box type or copy/paste 012000002090
Then press ENTER on your keyboard. Works right?

Now what I want to do is to be able to start typing the next UPC in the
box. But it doesn't let me, because the focus is set on the
commandbutton. I've tried setting txtUPC.setfocus at the end of
_AfterUpdate, but the focus stays on the command box.

I know I can use a commandbox instad of using the Enter button, but I
want to use the Enter button.


http://www.boltentertainment.org/helpme.xls

Share: 

 

2 Answers Found

 
Answer #1    Answered By: Shelia Wells     Answered On: Nov 30

I think you might find it works  real well if you do the following (I
downloaded your form and tried it myself):



1. set  the Default property on cmdAdd to True

2. Remove the AfterUpdate event handler

3. Go back to your "real" cmdAdd_Click handler instead of the ucmdAdd_Click
handler



I think the one key piece of missing info is the Default property on a
CommandButton. (You set it in the form designer, you know?)

 
Answer #2    Answered By: Roop Kapoor     Answered On: Nov 30

I also added

With Me.txtUPC
.SelStart = 0
.SelLength = Len(Me.txtUPC)
End With

to hilight whatever number is in the box

 
Didn't find what you were looking for? Find more on a really tough one - userforms Or get search suggestion and latest updates.




Tagged: