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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Defining fields through VBA create table statement

Status
Not open for further replies.

JoanieB

Programmer
Apr 17, 2001
57
US
I am creating a table through VBA and when I define my number fields, I want to specify # of decimal places - is there any way to do this?
Here's what I have now:

Dim NewInput As TableDef
Set NewInput = CurrentDb.CreateTableDef("TblInput")
With NewInput
.Fields.Append .CreateField("Cusip", dbText)
.Fields.Append .CreateField("Acct6", dbText)
.Fields.Append .CreateField("RecType", dbText)
.Fields.Append .CreateField("BBHNum", dbText)
.Fields.Append .CreateField("FundCode", dbDouble)
.Fields.Append .CreateField("FoxBal", dbDouble)
.Fields.Append .CreateField("BlushBal", dbDouble)
.Fields.Append .CreateField("OptCBal", dbDouble)
.Fields.Append .CreateField("OptRBal", dbDouble)
.Fields.Append .CreateField("UAFBal", dbDouble)
.Fields.Append .CreateField("PosNeg", dbText)
.Fields.Append .CreateField("Price", dbInteger)
.Fields.Append .CreateField("FundName", dbText)
.Fields.Append .CreateField("FundDesc", dbText)
.Fields.Append .CreateField("AcctName", dbText)
.Fields.Append .CreateField("ReconDate", dbDate)
CurrentDb.TableDefs.Append NewInput
End With
I want those Double fields to have 5 decimal places.
 
A double is any number from -1.79769313486231E308 to -4.94065645841247E-324 for negative values and from 4.94065645841247E-324 to 1.79769313486232E308 for positive values (OK, OK, I copied it from VB help!).
If you need to display numbers as 5dp then use FORMAT(<field>, &quot;0.#####&quot;) when you display them.

M :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top