TextBox exit routine 2nd try

  • Thread starter Patrick C. Simonds
  • Start date
P

Patrick C. Simonds

I use a 2 page multipage control (page 0 and Page 1) . On page 1 is
TextBox2203 which has an Exit routine (see below). My problem is that if
TextBox2203 is the active control and the user clicks on the tab to go to
page 0 of the multipage control, the exit routine for the TextBox does not
run. so is there any way to:

1. Get the exit routine to run if the user attempts to change pages without
exiting the the TextBox first.
2. If possible (but low priority) keep them on page1 if all the
OptionButtons are false.




Private Sub TextBox2203_Exit(ByVal Cancel As MSForms.ReturnBoolean)


Application.SpellingOptions.IgnoreCaps = False
Sheets("Sheet2").Unprotect

Sheets("Sheet2").Range("a1").Value = TextBox2203.Text
Application.EnableEvents = False
Sheets("Sheet2").Range("a1").CheckSpelling
Application.EnableEvents = True
TextBox2203.Text = ""
TextBox2203.Text = Sheets("Sheet2").Range("a1").Value
Sheets("Sheet2").Range("a1").Value = ""

If TextBox2203.Value <> rng1(1, 7) Then

OptionButton2201.Value = False
OptionButton2202.Value = False
OptionButton2203.Value = False
OptionButton2204.Value = False
OptionButton2205.Value = False
OptionButton2206.Value = False

End If

End Sub
 
D

Dave Peterson

How about moving the guts of the _exit routine to its own module.

Then have the MultiPage1_Change event call that procedure, too.

Or maybe disabling the tabs until everything is ok. Kind of like the
Previous/Next buttons on a lot of wizards.
 
P

Patrick C. Simonds

I did try coping the code into a standalone module and it worked to a point.
Problem was the that because it would move to page0. People complained that
when the spell check ran they wanted to be able to see the text that was
being checked.

How would one disable the tab to prevent them from going to page0 until the
exit routine had run? I do want them to be able to move between the pages as
long as they do not change anything in TextBox2203.
 

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