Set focus on the textbox after the message.

danbates

Active Member
Joined
Oct 8, 2017
Messages
377
Office Version
  1. 2016
Platform
  1. Windows
Hi,

I have the following code that triggers a message if one of the text boxes hasn't been entered.

Code:
If ((Me.TextBox2.Text = "") * (Me.TextBox3.Text = "") * (Me.TextBox4.Text = "") * (Me.TextBox5.Text = "") * (Me.TextBox6.Text = "") * (Me.TextBox7.Text = "") * (Me.TextBox8.Text = "") * (Me.TextBox9.Text = "")) Then
MsgBox "QTY not entered!", vbInformation, "Milk Room Operator"
    Exit Sub
    End If

What I would like is if the message is triggered, the message is ok'd then that textbox becomes active again with the curser flashing.

Any help would be much appreciated.

Thanks
Dan
 
I don't know what dropbox is Dave, sorry.
What I can do is start a thread on Excel Help Forum and put my file on there and then provide the link on here?
Would that be ok?
 
Upvote 0

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Hi,
Excel Help forum is not a site I am registered with but its a matter for you if want to start a thread there just be mindful of cross posting rules.

Mr Excel does not have the attach file option like other sites & most users here place their file in a dropbox (or similar) to enable file sharing.

More about Dropbox here:https://www.dropbox.com/individual

Dave
 
Upvote 0
Hi Dave,

Sorry I didn't get in touch yesterday, I was at a christening.

I've downloaded dropbox, how do I share the file with you?

Thanks

Dan
 
Upvote 0
just place file in a public folder & provide link to it here
 
Upvote 0
Try this update

Code:
For x = 2 To 9
    With Me.Controls("TextBox" & x)
        If .Visible And Len(.Text) = 0 Then
            MsgBox "QTY not entered!", 64, "Entry Required"
           If .Enabled Then .SetFocus
            Exit Sub
        End If
    End With
    Next x

Dave
 
Upvote 0
Hi Dave,

Yes that has sorted it. Thank you so much, it really is appreciated.

Kind Regards

Dan
 
Upvote 0

Forum statistics

Threads
1,224,828
Messages
6,181,204
Members
453,022
Latest member
RobertV1609

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