cancel sub ?

  • Thread starter Thread starter יריב החביב
  • Start date Start date
×

יריב החביב

Hello,

When enter data to a text box i dont want to let

the user exit the text box if some condition is maintain.

So, i wrote a code in the exit private sub that if the condition is maintain

it will produce message and will exit the sub (exit sub, end if).

But after the message is show it still exit the text box.

how will i prevent the user to go on if the condition is meet ?

THANK YOU
 
Hello,

When enter data to a text box i dont want to let

the user exit the text box if some condition is maintain.

So, i wrote a code in the exit private sub that if the condition is maintain

it will produce message and will exit the sub (exit sub, end if).

But after the message is show it still exit the text box.

how will i prevent the user to go on if the condition is meet ?

THANK YOU

It's not clear to me if the value must meet certain criteria or if the
value must NOT MEET that criteria.
Don't use the Exit event.
Use the control's BeforeUpdate event instead.

To meet certain criteria:
If Me.[ControlName] = Some Criteria then
MsgBox "You must enter a different value."
Cancel = True
End If

To NOT Meet that criteria:
If Me.[ControlName] <> Some Criteria then
MsgBox "You must enter a different value."
Cancel = True
End If
 
THANK YOU
--
תודה רבה


fredg said:
Hello,

When enter data to a text box i dont want to let

the user exit the text box if some condition is maintain.

So, i wrote a code in the exit private sub that if the condition is maintain

it will produce message and will exit the sub (exit sub, end if).

But after the message is show it still exit the text box.

how will i prevent the user to go on if the condition is meet ?

THANK YOU

It's not clear to me if the value must meet certain criteria or if the
value must NOT MEET that criteria.
Don't use the Exit event.
Use the control's BeforeUpdate event instead.

To meet certain criteria:
If Me.[ControlName] = Some Criteria then
MsgBox "You must enter a different value."
Cancel = True
End If

To NOT Meet that criteria:
If Me.[ControlName] <> Some Criteria then
MsgBox "You must enter a different value."
Cancel = True
End If
 

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

Back
Top