Data Type? 11.55 as Number

MagM

New Member
Joined
Sep 3, 2011
Messages
5
Hi, I would like to know what do I set the Number field to in property sect. I want double diget only and 2 decimel places only, eg 25.44. Thanks
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Hi, I would like to know what do I set the Number field to in property sect. I want double diget only and 2 decimel places only, eg 25.44. Thanks


'm new myself to access, tried looking here and there but I see no option to set the property type to the way you want.
However if you;re updating numbers from form maybe you can try
something like this:)
Code:
[/FONT]
[FONT=Courier New]Sub test101()
Dim ccc As String
ccc = 12.55
If ccc Like "*.*" And Len(ccc) = 5 Then
MsgBox "ok"
Else
MsgBox "not okay"
End If
End Sub[/FONT]
[FONT=Courier New]
 
Upvote 0
It's an interesting question. Why would it be a problem if a user entered a value with greater precision?

I.e.,
11.55432
Instead of:
11.55
 
Upvote 0
Set Field Size to Single, Format to 00.## and Decimal Places to 2.

This will still allow the user to enter values with more than 2 decimal places. though.

You could set up a validation rule I suppose.
 
Upvote 0
'm new myself to access, tried looking here and there but I see no option to set the property type to the way you want.
However if you;re updating numbers from form maybe you can try
something like this:)
Code:
[FONT=Courier New]Sub test101()
Dim ccc As String
ccc = 12.55
If ccc Like "*.*" And Len(ccc) = 5 Then
MsgBox "ok"
Else
MsgBox "not okay"
End If
End Sub[/FONT]
If the dats is numeric then you really should be using numeric data types.


Code:
If ccc Like "*.*" And Len(ccc) = 5 Then
The above has many log errors.

Here are some examples that incorrectly pass your logic:

Code:
? "1234." Like "*.*" and Len("1234.") = 5
True

? ".1234" Like "*.*" and Len(".1234") = 5
True
 
Upvote 0

Forum statistics

Threads
1,224,522
Messages
6,179,297
Members
452,903
Latest member
Knuddeluff

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