A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Setting Up & Running Reports
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Scroll a list box to selected item (Repost)



 
 
Thread Tools Display Modes
  #1  
Old May 18th, 2004, 12:53 AM
Nelson
external usenet poster
 
Posts: n/a
Default Scroll a list box to selected item (Repost)

I have code that selects an item in a list box that works fine (below) but I
would like to add code to scroll down to the selected item to show it. The
ListBox.Mutiselect is set to extended (3)

Anyone know how I would do that?
TIA
Nelson

If OpenArgs "" Then
For i = 0 To PatientList.ListCount - 1
If PatientList.ItemData(i) = OpenArgs Then
PatientList.Selected(i) = True
Exit For
End If
Next i
If i = PatientList.ListCount Then
DoCmd.Close
MsgBox "There are no claims to print for this patient."
End If
End If


  #2  
Old May 18th, 2004, 01:29 AM
Stephen Lebans
external usenet poster
 
Posts: n/a
Default Scroll a list box to selected item (Repost)

You can set the ListIndex prop to your var "i" in the sample code you
posted. Remember, the ListBox control MUST have the focus in order for
you to be able to write to the ListIndex prop.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.


"Nelson" wrote in message
...
I have code that selects an item in a list box that works fine (below)

but I
would like to add code to scroll down to the selected item to show it.

The
ListBox.Mutiselect is set to extended (3)

Anyone know how I would do that?
TIA
Nelson

If OpenArgs "" Then
For i = 0 To PatientList.ListCount - 1
If PatientList.ItemData(i) = OpenArgs Then
PatientList.Selected(i) = True
Exit For
End If
Next i
If i = PatientList.ListCount Then
DoCmd.Close
MsgBox "There are no claims to print for this patient."
End If
End If



  #3  
Old May 18th, 2004, 01:36 AM
Nelson
external usenet poster
 
Posts: n/a
Default Scroll a list box to selected item (Repost)

Stephen,

That did it! Thanks! I didn't try the listindex property since VB help
states it is read only. Thanks again.

Nelson

"Stephen Lebans"
wrote in message ...
You can set the ListIndex prop to your var "i" in the sample code you
posted. Remember, the ListBox control MUST have the focus in order for
you to be able to write to the ListIndex prop.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.


"Nelson" wrote in message
...
I have code that selects an item in a list box that works fine (below)

but I
would like to add code to scroll down to the selected item to show it.

The
ListBox.Mutiselect is set to extended (3)

Anyone know how I would do that?
TIA
Nelson

If OpenArgs "" Then
For i = 0 To PatientList.ListCount - 1
If PatientList.ItemData(i) = OpenArgs Then
PatientList.Selected(i) = True
Exit For
End If
Next i
If i = PatientList.ListCount Then
DoCmd.Close
MsgBox "There are no claims to print for this patient."
End If
End If





  #4  
Old May 18th, 2004, 02:16 AM
Stephen Lebans
external usenet poster
 
Posts: n/a
Default Scroll a list box to selected item (Repost)

Never believe everything you read!grin
:-)

--
HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.


"Nelson" wrote in message
...
Stephen,

That did it! Thanks! I didn't try the listindex property since VB

help
states it is read only. Thanks again.

Nelson

"Stephen Lebans"


wrote in message ...
You can set the ListIndex prop to your var "i" in the sample code

you
posted. Remember, the ListBox control MUST have the focus in order

for
you to be able to write to the ListIndex prop.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.


"Nelson" wrote in message
...
I have code that selects an item in a list box that works fine

(below)
but I
would like to add code to scroll down to the selected item to show

it.
The
ListBox.Mutiselect is set to extended (3)

Anyone know how I would do that?
TIA
Nelson

If OpenArgs "" Then
For i = 0 To PatientList.ListCount - 1
If PatientList.ItemData(i) = OpenArgs Then
PatientList.Selected(i) = True
Exit For
End If
Next i
If i = PatientList.ListCount Then
DoCmd.Close
MsgBox "There are no claims to print for this patient."
End If
End If






  #5  
Old May 18th, 2004, 03:24 AM
Nelson
external usenet poster
 
Posts: n/a
Default Scroll a list box to selected item (Repost)

Especially if it is in Microsoft helpless (oops, I meen help) files.

"Stephen Lebans"
wrote in message ...
Never believe everything you read!grin
:-)

--
HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.


"Nelson" wrote in message
...
Stephen,

That did it! Thanks! I didn't try the listindex property since VB

help
states it is read only. Thanks again.

Nelson

"Stephen Lebans"


wrote in message ...
You can set the ListIndex prop to your var "i" in the sample code

you
posted. Remember, the ListBox control MUST have the focus in order

for
you to be able to write to the ListIndex prop.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.


"Nelson" wrote in message
...
I have code that selects an item in a list box that works fine

(below)
but I
would like to add code to scroll down to the selected item to show

it.
The
ListBox.Mutiselect is set to extended (3)

Anyone know how I would do that?
TIA
Nelson

If OpenArgs "" Then
For i = 0 To PatientList.ListCount - 1
If PatientList.ItemData(i) = OpenArgs Then
PatientList.Selected(i) = True
Exit For
End If
Next i
If i = PatientList.ListCount Then
DoCmd.Close
MsgBox "There are no claims to print for this patient."
End If
End If








 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 12:10 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.