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

For Each - Next

P: n/a
Hi!
How do I trap if nothing is selected from the listbox in the code below?
TIA

Sigurd

For Each varItem In Me![lstUtskrift].ItemsSelected

intFakturanr = Me![lstUtskrift].Column(0, varItem)
DoCmd.OpenReport "rptFaktura", acNormal, "", "[Fakturano]=" &
intFakturanr
DoEvents

Next varItem
--
____________________________________________
KILLSPAM R e m o v e trippleX to reply
to email adress.
Nov 12 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Check the Count property of the ItemsSelected collection?

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html

"Sigurd Bruteig" <s-********@online.no> wrote in message
news:LQ********************@news2.e.nsc.no...
Hi!
How do I trap if nothing is selected from the listbox in the code below?
TIA

Sigurd

For Each varItem In Me![lstUtskrift].ItemsSelected

intFakturanr = Me![lstUtskrift].Column(0, varItem)
DoCmd.OpenReport "rptFaktura", acNormal, "", "[Fakturano]=" &
intFakturanr
DoEvents

Next varItem

Nov 12 '05 #2

P: n/a
"Sigurd Bruteig" <s-********@online.no> wrote in message news:<LQ********************@news2.e.nsc.no>...
Hi!
How do I trap if nothing is selected from the listbox in the code below?
TIA

Sigurd

For Each varItem In Me![lstUtskrift].ItemsSelected

intFakturanr = Me![lstUtskrift].Column(0, varItem)
DoCmd.OpenReport "rptFaktura", acNormal, "", "[Fakturano]=" &
intFakturanr
DoEvents

Next varItem


Try this

If Me![lstUtskrift].ListIndex < 0 then
MsgBox"You must make a selection"
Exit Sub
End If

David
Nov 12 '05 #3

P: n/a

I got this code to work before I read David's answer.

intIsSelected = (Me![lstUtskrift].ItemsSelected.Count)
If intIsSelected < 1 Then MsgBox "Select report"

Davids code: If Me![lstUtskrift].ListIndex < 0 then
MsgBox"You must make a selection"
also worked!

Thank you both!

Sigurd

Nov 12 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.