Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Not able to set decimal places through vba, why?

Status
Not open for further replies.

lingyi

Programmer
Apr 11, 2001
65
SG
Hi,
I passed this parameter to the function in order to set the decimal places of field.
SetFieldProperty "tblOrderItems", "OrderItemsWeight", "DecimalPlaces", 12, 2

my setFieldProperty function

Set tbl = dbs.TableDefs(tblName)
tbl.Fields.Refresh
Set fld = tbl.Fields(fldName)
Set l_prp = fld.Properties(propName)
If IsNull(value) Then
fld.Properties.Delete propName
Else
l_prp.value = value
End If

It didnt prompted any eiror yet when i go to check the field, the decimal places does not set at all, I dont understand why, pls help! Thanks.
 
lingyi: In many cases you can force a format as follows:

MyNum = Format(MyNum, "00.00")

..and if MyNum = 1345.02234343 you get back 1345.02

..however, this changes the number to a string but you can recapture the number as:

MyDbl = Val(MyNum)

...just one of many ways to do this...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top