Exit Do problem

J

Jeff

Hi,

My code for a Print button is as follow:

Private Sub btnPrint_Click()
.............
strCode = ""
Do While Validate(strCode) = False
strCode = InputBox("Please, enter code", "Print Table")

Loop
...............
End Sub

The cancel button on my InputBox doesn't work. I need to let people exit the
Do While Loop if they want to cancel. Thank you.
 
J

Jeff

Hi,

Thank you for your quick response. I am not sure what to put in my If clause
or how let Exit Do work if people press the Cancel button.
If ....... Then
Exit Do
End If
 
J

John Spencer

If Len(strCode) = 0 Then
Exit Do
ELSE
'do stuff here
END IF

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County
 
D

Daniel Pineault

Try something like:

Private Sub btnPrint_Click()
.............
strCode = ""
Do While Validate(strCode) = False
strCode = InputBox("Please, enter code", "Print Table")
If strCode = "" Then Exit Do
Loop
...............
End Sub

--
Hope this helps,

Daniel Pineault
http://www.cardaconsultants.com/
For Access Tips and Examples: http://www.devhut.net
Please rate this post using the vote buttons if it was helpful.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top