By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,384 Members | 714 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,384 IT Pros & Developers. It's quick & easy.

listbox- how to get first item only

P: n/a
I have a list box where the user might need to select two items which builds
up an sql string. Another part of the function only requires the first item.

here is the code :
For Each varItems In Me.ListDOS.ItemsSelected

If strMods = vbNullString Then
strMods = "=" & """" & Me.ListDOS.Column(1, varItems) & """"
Else
strMods = "=" & """" & Me.ListDOS.Column(1, varItems) & """"
End If
Next varItems

I am not sure how to amend it so that it reaches only the first item, stores
it to strMods and then drops out of the loop.

regards in advance.

Peter
Nov 13 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

' this is a very easy solution
' probably a much more elegant one, that I can't think of

For Each varItems In Me.ListDOS.ItemsSelected
If strMods = vbNullString Then
strMods = "=" & """" & Me.ListDOS.Column(1, varItems) & """"
Else
strMods = "=" & """" & Me.ListDOS.Column(1, varItems) & """"
End If

exit for

Next varItems

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQUcyjIechKqOuFEgEQL6cQCeOLdsBH9G+0KlV0bKYm+Dxz XNHvcAoMXX
EOWcSgKVvpX4nBXh9slLg+0x
=MOof
-----END PGP SIGNATURE-----
Peter Bailey wrote:
I have a list box where the user might need to select two items which builds
up an sql string. Another part of the function only requires the first item.

here is the code :
For Each varItems In Me.ListDOS.ItemsSelected

If strMods = vbNullString Then
strMods = "=" & """" & Me.ListDOS.Column(1, varItems) & """"
Else
strMods = "=" & """" & Me.ListDOS.Column(1, varItems) & """"
End If
Next varItems

I am not sure how to amend it so that it reaches only the first item, stores
it to strMods and then drops out of the loop.


Nov 13 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.