Hi,
I'm looking for the answer to this please...
I have a text box and I want it so that if the user has not typed in the number 1 then it won't let him leave the box.
Can anyone tell me how to do this?
Thanks
John
Hi,
I'm looking for the answer to this please...
I have a text box and I want it so that if the user has not typed in the number 1 then it won't let him leave the box.
Can anyone tell me how to do this?
Thanks
John
Hi,
i recently used something like this....
guess you would have this...![]()
If Trim(Me.txtDate) = "" Then MsgBox ("Please Enter a Recieved Date.") Me.txtDate.SetFocus Exit Sub End If
HTH![]()
If Trim(Me.txtbox1) = 1 Then MsgBox ("Please Enter a 1") Me.txtbox1.SetFocus Exit Sub End If
Spinkung.![]()
Hi, thanks for the quick reply..
My code is
Private Sub TextBox1_AfterUpdate()
If TextBox1.Value <> "1" Then
MsgBox "This should be 1"
Me.TextBox1.SetFocus
End If
End Sub
This code recognises that 1 hasn't been entered and returns the correct msgbox but it still jumps to the next box.
Any ideas?
Thanks
John
Hi,
HTH![]()
Private Sub TextBox1_Change() Dim okstop As Boolean Dim yesno_continue As Boolean Dim mytext As String okstop = False Do mytext = TextBox1.Value If Not IsNumeric(mytext) And mytext <> "" Then TextBox1.Value = "" 'Clears the TextBox 'Shows a message box that informs you that you typed 'something other than a number. yesno_continue = MsgBox("Please type only numbers." & _ Chr(13) & "Continue?", vbYesNo) Else okstop = True 'You typed a number in the TextBox. End If 'Continue with the loop if you click Yes. 'Stop the loop if they typed a number in the TextBox. Loop Until (yesno_continue = vbNo) Or (okstop = True) End Sub
Carim
![]()
Thanks for the reply.
I tried your method (I had to edit it to suit) but the msgbox keeps coming back up every time I cancel it and I have to close Excel to start working again.
Thanks for your help but I think I am just going to leave it for now.
Cheers
John
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks