How to allow only Numeric value in textbox1 of form1....

pedie

Well-known Member
Joined
Apr 28, 2010
Messages
3,875
How can i make users enter numbers only in the textbox1 in form1. this textbox is unbound.
Also how can i enter default value...like (Click here to enter x value)


Thanks for helping.
Pedie
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Try this out.

Open the form in design view > select unbound text box > open properties > select Events > On Exit > select Elipsee and Code Builder add this code

Private Sub Text16_Exit(Cancel As Integer)
If IsNumeric(Me.Text16) = False Then
MsgBox "This isn't numeric"
Me.Text16 = ""

Else
Exit Sub
End If

End Sub
 
Upvote 0
Pedie

What data type is the field that's the control source of this textbox?

If it's Numeric Access won't allow the user to enter a number.

You don't really need code to do that - this isn't a userform.
 
Upvote 0
Norie, there is no control source, form is not connected to any table...
You right i also check and realise that we can take control of this from the format properties:)

Thanks again


What data type is the field that's the control source of this textbox?

If it's Numeric Access won't allow the user to enter a number.

You don't really need code to do that - this isn't a userform.

 
Upvote 0
Pedie

Why is there no control source? What is this textbox for?

Is there a record source for the form itself?
 
Upvote 0

Forum statistics

Threads
1,215,064
Messages
6,122,942
Members
449,094
Latest member
teemeren

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