Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default Forced Input

I have a number of text boxes.

The user can not enter the same text into any two text boxes.

This is the part of the code that traps the error.

____________________
If text1 = text2 Then

Dim Med, Uts, Titel, Respons
Med = ("The name " & Text1 & " already exists")
Titel = "Name Entry Error"
Respons = MsgBox(Med, vbOKOnly, Titel)
_____________________


But this does not stop the user from clicking ok and ignoring the
message and clicking on another text box.

How can I force the user to enter correct text in textbox before
allowing them to leave the form. What I really want is to go back to the
original text in the textbox if they fail to enter a valid name.

I have tried this with
TextBox1.change and
TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)

But I am still not quite there. Grateful if anyone can point me in the
right direction.

Garry Jones
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Forced Input

In the Exit event, you can set cancel = true and the user will not exit the
text box. You can also clear the textbox at that time as well

Text2.Value = ""

--
Regards,
Tom Ogilvy

Garry Jones wrote in message
...
I have a number of text boxes.

The user can not enter the same text into any two text boxes.

This is the part of the code that traps the error.

____________________
If text1 = text2 Then

Dim Med, Uts, Titel, Respons
Med = ("The name " & Text1 & " already exists")
Titel = "Name Entry Error"
Respons = MsgBox(Med, vbOKOnly, Titel)
_____________________


But this does not stop the user from clicking ok and ignoring the
message and clicking on another text box.

How can I force the user to enter correct text in textbox before
allowing them to leave the form. What I really want is to go back to the
original text in the textbox if they fail to enter a valid name.

I have tried this with
TextBox1.change and
TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)

But I am still not quite there. Grateful if anyone can point me in the
right direction.

Garry Jones



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Forced to save - even if no changes RJB Excel Discussion (Misc queries) 2 December 13th 07 04:26 PM
Forced Scaling [email protected] Charts and Charting in Excel 0 May 17th 07 06:33 PM
Forced Cell Input in Excel 2002 Josh Excel Discussion (Misc queries) 5 February 15th 07 07:36 PM
Forced return?? WTG Excel Worksheet Functions 4 March 7th 06 05:47 PM
Forced Distribution Mark Excel Worksheet Functions 3 November 2nd 04 11:43 PM


All times are GMT +1. The time now is 01:09 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"