LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default message box error trapping issue

I need some help resolving an issue where my msgbox goes into a terminal loop.

I have a form with a runtime-generated list of names with check boxes next to each, plus €˜Go and €˜Cancel buttons. When the user launches the routine, the list box populates with names it reads from within the file. The user selects the names of the individuals he/she is interested in and the routine launches without issue.

As part of the code, I have error traps for canceling and exiting the routine for various reasons. They all work normally, except for the condition where the user clicks the launch button with no names selected. I have the following error trap code:


sub ChooseNames
dim i as Integer, j as Integer
Dim bFlg as Boolean

' some code ....

resetChoice:

j = 0

bFlg = False

For i = 0 To form1.ListCount - 1
' run through list box of names looking for
If form1.Selected(i) = True Then
'do some action here
j = j + 1 €˜ index to next name in list
bFlg = True
End If
Next i

€˜ error trap
If bFlg = False Then
MsgBox "Select one or more names, then click " & _
"'Go or click 'Cancel'", vbInformation, "Selection Required"
GoTo resetChoice
End If

' more code ....

End Sub


If any name is selected the bFlg is tripped to TRUE and the code executes normally. If no names are selected bFlg remains false and the error trap is activated. If the user responds to the message and selects €˜Cancel, the routine exits normally. If the user hits the €˜Go button without any of the names being selected, the message reappears and even with the form set to modal as true, I cant select anything in the list box or get the message box to disappear. So effectively, the user is stuck in a message box loop.

Any suggestions on how to display the message and allow the user to select from the run time list or cancel and exit?

Art
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Trapping Error Message Harn88 Excel Programming 1 December 3rd 09 04:01 AM
Error Trapping Issue? WorksheetFuntion.Search Don Excel Programming 1 December 8th 07 05:10 PM
Error Trapping gazza67[_2_] Excel Discussion (Misc queries) 2 September 6th 07 06:11 PM
while deleting rows it finds an error - error trapping Janis Excel Programming 2 July 19th 07 12:12 AM
Trapping warning message Tom Ogilvy Excel Programming 0 December 20th 03 03:09 PM


All times are GMT +1. The time now is 02:45 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"