MsgBox appearing when not wanted

Noz2k

Well-known Member
Joined
Mar 15, 2011
Messages
693
I have this code on the first textbox on a userform

Code:
Private Sub Textbox1_AfterUpdate()
If Not Textbox1.Value Like "*[ ]*" Then
MsgBox "Must include both First & Second Name"
Cancel = True
Textbox1.SetFocus
End If
End Sub

The problem I am having is because the focus is set to begin in this textbox after I send a record to excel, it generates the msgbox before the user has a chance to enter any data.

The same thing happens if the user clicks the little x in the corner of the form if the cursor is in this textbox at the time.

Is there a way to prevent this from happening?
 
Well I think the logic place to put the check for a future date would be after you've checked it is a date.
 
Upvote 0

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Yeah, I have now added it to the exit event.

It just bothers me that it tells the user it is correct until they exit that textbox. But nevermind, can't be perfect I guess.

Thanks for all your help
 
Upvote 0
Sorry I don't understand, can you post your code?

Are you actually showing a message saying it's correct?

Do you want to monitor every change in the textbox to make sure its OK?
 
Upvote 0

Forum statistics

Threads
1,224,597
Messages
6,179,813
Members
452,945
Latest member
Bib195

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top