Help with text boxes on User form


Posted by Christine on March 24, 2001 2:22 AM

Hi One and All.

I am seeking some help with the following. I have a user form that I am using to input data into an excel speadsheet. I have used text boxes for some information. What I would like is for went the user does not enter a value into the textbox and tabs onto the next box, a message box pops up advising them that a value must be entried. I have though of an if then else statement but can not get this to work. The boxes pop up and when you press ok, the null value is entried onto the spreadsheet.

All help would be greatly appreciated.

Regards
Christine
Darwin Australia

Posted by Dave Hawley on March 24, 2001 3:17 AM

Hi Christine

I can't help but help a fellow Oz.

Try this:

Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)

If TextBox1.Value = "" Then
Cancel = True
MsgBox "You must enter a value!"
Exit Sub
Else: Select Case TextBox1
Case IsNumeric(TextBox1)
MsgBox "Number"
Case Else
MsgBox "Text"
End Select
Cancel = False
End If
End Sub


BTW hows the weather up there?


Dave

OzGrid Business Applications



Posted by Christine on March 24, 2001 3:28 AM

Hi Dave

Many thanks for your help. I am going to try it in the morning.

The weather is not too bad for this time of the year, a few storms - temps around 32c. Darwin would have to be one of the best places on earth.

Regards

A True Territorian.