HTH. Best wishes Harald
> Problem was the enter key does nothing in a listbox, but in a textbox it
> assigns the value you entered and sets focus to the next field in tab stop
> order.
> Thanks this worked
> Private Sub FListItem_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
> If KeyAscii = vbKeyReturn Then 'traps enter key pressed
> FListItem.Value = FListItem.ListIndex ' assigns the value selected
to
> the listbox.value
> FItemPrice.SetFocus 'moves focus to next textbox
> End If
> End Sub
> Now to make it generic so it can be used in all list boxes
> Or would doing so just slow down the program?
> Which way would be the most effecient? Generic or just the code like
above?
> Hmm...
> Private Sub FListItem_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
> handle_listbox_enter "FListItem"
> End Sub
> Sub handle_listbox_enter(ByVal Listname as String)
> Listname.Value = Listname.ListIndex ' assigns the value selected to the
> listbox.value
> FItemPrice.SetFocus 'moves focus to next textbox
> End Sub
> returns Variable not defined on listname
> Ideas?
> --
> Carl & Linda Brehm
> Lake Lafourche Bird House
> Keets, Tiels, GN & Red Lories, Quakers
> Plum Head, Mitred Conures, TAG's
> Bird Toys, Cages, Feed & Supplies
> > >Need to trap for enter and sendkey left tab or tab.
> > >Private Sub FListItem_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
> > > if Chr(KeyAscii) = "11" sendkey Chr "9"
> > >End Sub
> > I think this is what you're after:
> > Private Sub FListItem_KeyPress(ByVal KeyAscii _
> > As MSForms.ReturnInteger)
> > If KeyAscii = vbKeyReturn Then
> > SendKeys "{Tab}"
> > End If
> > End Sub
> > However Sendkeys is generally regarded as a buggy P.O.S. If your
> > intention is to move to another control on the form (I'm assuming
> > textboxes here, but the principle still holds for any control), it
> > would be better to just set the focus to the other control rather than
> > simulating the user tabbing to it. For example:
> > Private Sub FListItem_KeyPress(ByVal KeyAscii As
> > MSForms.ReturnInteger)
> > If KeyAscii = vbKeyReturn Then
> > TextBox2.SetFocus
> > End If
> > End Sub
> > ---------------------------------------------------------
> > Hank Scorpio
> > scorpionet who hates spam is at iprimus.com.au (You know what to do.)
> > * Please keep all replies in this Newsgroup. Thanks! *
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.408 / Virus Database: 230 - Release Date: 10/24/2002