Go to 1st item in Listbox

S

Stephen Lynch

I am having trouble utilizing the onclick event on a tabcontol to set the
focus on a listbox. I want it to go to the first item in the listbox when
the tab is clicked.

List Box Name: lstboxEligibility
 
L

Linq Adams via AccessMonster.com

The Click event is essentially useless on Tabbed Pages. You have to use the
Change event to identify which page has been selected. The Pages are Zero-
based, just like the ItemData is for the listbox, so the value of the first
page is 0, the second page is 1, and so forth.

Private Sub YourTabControl_Change()
If YourTabControl = 1 Then
lstboxEligibility = lstboxEligibility.ItemData(0)
End If
End Sub

This assumes that

lstboxEligibility

resides on the second tabbed page. Modify the line

If YourTabControl = 1 Then

to reflect the actual tabbed page, and replace

YourTabControl

with the actual name of your tabbed control.
 
S

Stephen Lynch

Thanks Linq:

I was starting to figure it out. I put code in a button and it worked but
the tabs failed, so I got confused.

So I appreciate you saving me the time. Have a good day.

Steve
 
L

Linq Adams via AccessMonster.com

Glad to help! Tabbed pages are great, but they take a little getting used to!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top