Programmatically select a record in a list box

mvorous

mvorous
Local time
Today, 09:50
Joined
May 29, 2008
Messages
46
Hello, I have a form with a simple list box of records. I would like to click a button and have a particular record selected -"highlighted" as if actually clicked upon by user. Can this be done?
Thank you, mvorous
 
Generally,

Me.ListBoxName.Selected(x) = True

where x is the record to be selected (first record is zero).
 
I tried the following code to "select" the 87th record out of 100 & nothing happened. Any advice?


Private Sub CmdBtn_Click()
Me.Patientlist.Selected(87) = True
End Sub


Thank you, mvorous
 
Your code should have worked wiith one change. The index is zero based, so the syntax doe the 87th record would have been

Me.Patientlist.Selected(86) = True

What version of Access are you using? Does other VBA code work?
 
I am using Access 2007 to create a DB for Access 2000.
I knew about the zero based thing, but really "nothing" happens when I do this.
Yes, other VBA code works fine.
mvorous
 
That worked fine, I don't know what I did at first but thank you all very much.
mvorous
 

Users who are viewing this thread

Back
Top Bottom