Exit Do problem

  • Thread starter Thread starter Jeff
  • Start date Start date
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.
 
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
 
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
 
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.
 
Back
Top