Basic Error Handling Q.

L

Lethoric

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?
 
M

MDW

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
 

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