gusbrunston
Programmer
Hi:
I need to force a user to enter a string in a msg box, "Why is this check being voided?"
I've used outer and inner loops to poll for the string entry. I think it works, but each time it results in an endless loop!
How do I trap for the escape key? And why won't my code kick user out when an answer is entered in the msg box?
1. Is there a better way?
2. Why doesn't the escape key get me out?
3. Why won' user's data entry exit loops?
Appreciate your comments very much.
[tt]Gus Brunston - Access2000(DAO)
Skill level based on 1-10: 7
Webmaster: www.rentdex.com[/tt]
I need to force a user to enter a string in a msg box, "Why is this check being voided?"
I've used outer and inner loops to poll for the string entry. I think it works, but each time it results in an endless loop!
How do I trap for the escape key? And why won't my code kick user out when an answer is entered in the msg box?
Code:
'User must enter a reason in the msg box
Dim strReason As String
Dim KeyCode As Integer
Dim checkReason
checkReason = True
strReason = ""
Do 'Outer loop
Do While strReason = "" 'Inner loop
strReason = InputBox("Why is this check " _
"being voided?", _
"Why void check?")
'trap for escape key to avoid endless loop
If KeyCode = vbKeyEscape Then
'the default reason
strReason = "Misprinted"
checkReason = False 'exit outer loop
Exit Do 'exit inner loop
End If
If strReason = "" Then
checkReason = True
End If
Loop
Loop Until checkReason = False
Me.txtReason = strReason 'the reason for this!
1. Is there a better way?
2. Why doesn't the escape key get me out?
3. Why won' user's data entry exit loops?
Appreciate your comments very much.
![[glasses] [glasses] [glasses]](/data/assets/smilies/glasses.gif)
Skill level based on 1-10: 7
Webmaster: www.rentdex.com[/tt]