View Full Version : Changing a DataType using VBA
BarkersIT
04-19-2007, 04:18 AM
I have a table with a single field and the Datatype is Number.
How can I set the Decimal Places attribute using VBA?
Create a Query based on the "export" table.
In a New column Heading enter this
newcost: Format(Int([cost]*100)/100,"Fixed")
where [cost] is the actual name of your "Currency" field.
If you compare the 2 columns you will see that the new one is just a "number" field, it is no longer Currency.
omocaig
04-19-2007, 09:32 AM
if you want to change the decimal places value in the table properties you can use the following code:
Sub x()
CurrentDb.TableDefs("data").Fields("num").Properties("DecimalPlaces") = 2
End Sub
omocaig
04-19-2007, 09:33 AM
If you want to change the decimal places value in the table properties you can use the following code:
Sub x()
CurrentDb.TableDefs("yourTableName").Fields("yourFieldName").Properties("DecimalPlaces") = 2
End Sub
replacing yourTableName and yourFieldName with the actual table/field names.
hth,
Giacomo
EDIT: oops! sorry about the double post
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.