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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Autoselection in ListBOX

Status
Not open for further replies.

Compuboy

Programmer
Jun 8, 2004
38
US
My DB is in Access 2002.
HOW would I automatically select the lastest item in the listbox. For example, in my DB when a record is added it automatically goes into the list box, what code do I need to automatically highlight this record. (Replacing the code below)

I've been using the following code to select the first item in the list box:

If CordLB.ListCount > 0 Then
CordLB.SetFocus
CordLB.ListIndex = 0
End If
 
Probably...
dim l as Long

If CordLB.ListCount > 0 Then
CordLB.SetFocus
l = CordLB.ListCount
CordLB.ListIndex = l-1
End If
 
I tried that. And what that does is select the last item in the list. Since my listbox is ordered alphabetically...it would select the item that begins with Z even if the one I just entered begins with G or something like that.

I want to know how to select the one that was just entered.
 
How are ya Compuboy . . . . .

Need something to ping on. Is the PK in the listbox & record?

If not something common?

Calvin.gif
See Ya! . . . . . .
 
Compuboy . . . . .

Sorry . . . .

PK same as [blue]PrimaryKey[/blue]

FK same as [blue]ForeignKey[/blue]

Used alot in the forums . . . .

Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top