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!

Goto very first record in listbox and highlight 1

Status
Not open for further replies.

macca007

Programmer
May 1, 2004
86
GB
Hi,

My situation is after person has selected a patient from
a combo box, many treatments are shown in a listbox (1 to many relationship).

What i would like to do is when a patient is selected from combo box i would like the first record on the listbox to be selected and highlighted.

Can this be done? It would be great if sample code could get me started, or even code to show select first record and highlight.

cheers
 
Hi,

If the listbox is already full you need to use the ListItems Collection to choose the first record:

Code:
[COLOR=blue]
[i]ListBox1[/i].ListItems(1).Selected = True
[/color]

Change ListBox1 to the name of your control.

Hope this helps,
Dean :)
 
thanks for the reply dean

lstClinicalDetails.ListItems(1).Selected = True

i get the following error on listitems "method or data member not found"

 
Finally worked it out.

lstClinicalDetails.Selected(0) = True

nearly similar to yours but it helped.
 
just an idea, but have you tried creating a subform with your listbox on it, and a gotorecord procedure on this whenever the combo box value is changed?
 
For MS Access you have to use
Code:
Me.lstClinicalDetails.Selected(0) = True
Remember !! list count starts form 0 not 1


Zameer Abdulla
[sub]Jack of Visual Basic Programming, Master in Dining & Sleeping[/sub]
Visit Me
 
Macca007, Your post came first.. I was getting an OOPS.. screen for a long time. Good you solved it

Zameer Abdulla
[sub]Jack of Visual Basic Programming, Master in Dining & Sleeping[/sub]
Visit Me
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top