473,394 Members | 1,671 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

For Each - Next

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
3 11085
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
"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

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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Marcel | last post by:
Hello, I'm working on a search application for my website. The website contains a lot of pictures, and a search should return clickable thumbnails. No problems there. My problem started when I...
2
by: Bengt Richter | last post by:
Is this a well known bug that's been fixed? I couldn't find any discussion of it, but maybe my googling's off today ;-/ >>> def foo(): ... it = iter(range(10)) ... while True: ... ...
7
by: simonwittber | last post by:
>>> gen = iterator() >>> gen.next <method-wrapper object at 0x009D1B70> >>> gen.next <method-wrapper object at 0x009D1BB0> >>> gen.next <method-wrapper object at 0x009D1B70> >>> gen.next...
2
by: Deniz Bahar | last post by:
Hi, I'm working with a single linked list and want to delete elements by searching through the list (starting form the HEAD) then finding the element, then doing the following: NewElement =...
9
by: Steven D'Aprano | last post by:
I'm looking for some way to get the next floating point number after any particular float. (Any mathematicians out there: I am aware that there is no "next real number". But floats are not real...
13
by: Joseph Garvin | last post by:
When I first came to Python I did a lot of C style loops like this: for i in range(len(myarray)): print myarray Obviously the more pythonic way is: for i in my array: print i
7
by: fniles | last post by:
In VB 6.0 in the error trapping, we can do "resume next" to continue on the next code. How can we do that in .NET with "Try", "Catch","End Try" ? Thanks
4
by: Neo | last post by:
I found on error resume next doesn't work in for each... e.g. on error resume next for each x in y 'do stuff next if you have an error in for each loop, it falls in infinite loop... it...
0
ADezii
by: ADezii | last post by:
If you want to visit each item in an Array, you have two alternatives: Use a For Each..Next loop, using a Variant to retrieve each value in turn. Use a For...Next loop, looping from the Lower...
2
ADezii
by: ADezii | last post by:
If you are executing a code segment for a fixed number of iterations, always use a For...Next Loop instead of a Do...Loop, since it is significantly faster. Each pass through a Do...Loop that...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.