Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

AutoSelecting the first entry in a list box when it is opened.

Status
Not open for further replies.

BrentJ

Technical User
Aug 2, 2004
29
US
I have a form with a list box. The list box is the only editable item on the form. When an item is selected it opens a modal form to edit the record. The problem is that when the form with the list box first opens, the list box has the focus but you have to hit the down key or click on one of the entries to get it to select any of the entries, so if the enter key is pressed to edit the record when the form is first opened it creates a new unwanted record. I need to have the list box select the first entry in the list when the form is first opened. I have tried using the sendkeys command to send the down arrow OnLoad, and OnGotFocus for both the form and the control but this did not work. Any Ideas? Thanks.

Brent
 
Try something like this in the forms load?

me("NameOfTheList").Selected(0)=True

(think use 1 if you're showing the column heads)

Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top