Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to stop the procedure instead of continuing sending a mail after none of criteria match

0 views
Skip to first unread message

Gerry

unread,
Nov 15, 2007, 10:58:59 AM11/15/07
to
Hello

Descprition of situation:

As you can see here we have a loop (While not ... Wend) which contains
2 'case conditions'.
What is my problem. At the end of this piece of code there is more
code that prepares a mail containing all constatations.
My problem:
In case none of the 'case criteria' match I want to end the procedure
preliminary so the mail doesn't have to be sent.
Can anybody tell me how I have to proceed? Thanks a lot!

<check of files in a Recordset>

nomb = Rs1.RecordCount
Rs1.MoveFirst
While Not (Rs1.EOF)

resultstr = ""
Posnr = Rs1.Fields("Position")
Instrnr = Rs1.Fields("INSTRUMENT")
Select Case Abs(Rs1.Fields("Position"))

Case 5 To 10
resultstr = Instrnr & ":" & Posnr & "EUR"
MsgBox ("Nobody ")

Case 11 To 20
resultstr = resultstr & Instrnr & ":" & Posnr & "EUR"
MsgBox ("Go for It")

End Select
Rs1.MoveNext
Wend
MsgBox ("All Positions checked!")

.... ?? ..... If the criteria don't match, the mail that is generated
hereafter doesn't have to be sent.

<code which creates a general mail containing constatations even if
there is nothing relevant to mention>


Stuart McCall

unread,
Nov 15, 2007, 11:27:14 AM11/15/07
to
"Gerry" <geert.van...@dexia.be> wrote in message
news:e0ecd190-934b-458b...@y5g2000hsf.googlegroups.com...

Insert the line:

If resultStr <> "" Then Exit Sub

after your MsgBox line.

Dom

unread,
Nov 15, 2007, 4:32:01 PM11/15/07
to
You can add an additional Case Statement as follows

Case Else
rs1.movelast

Then the rs1.EOF will validate the While loop.

"Gerry" wrote:

> ..... ?? ..... If the criteria don't match, the mail that is generated

0 new messages