Basic Error Handling Q.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Greetings;

I'm writing a program that asks multiple questions of the user before producing the requested data.

The questions and pulling up the data is fine, but if the Client click's cancel of the first question, the second question pops up still... and if they press cancel again, etc... you'll get a program error.

How do I get it to cancel or ignore the rest of the program if the client cancels the process?
 
Depends on how you're getting your values. Are you using MsgBox commands? If so, you could do something like this:

vntResponse = MsgBox("Your question here",vbYesNoCancel)
If vntResponse = vbCancel Then ' I THINK the named constant is vbCancel...check on that
MsgBox "Cancel pressed. Exiting."
Exit Sub
End If

An alternative would be:

Do

vntResponse = MsgBox("Your question here",vbYesNoCancel)

Loop While vntResponse <> vbCancel

The latter would FORCE users to supply valid data.

HTH
 
Back
Top