Click to See Complete Forum and Search --> : Change the default Text format of a field


Dr_Michael
December 17th, 1999, 04:24 AM
With the following code I create some mdb files with one table and appropriate records from a recordset. How can I set some of the fields to be Number, or Date, or Currency Format and not the default Text format???


'creates the DataBase
Const lngDB_Text as Long = 10
Const intFieldLength as Integer = 100
'Create new instance of Microsoft Access
set appAccess = CreateObject("Access.Application.9")
'Open database in Microsoft Access window but invisible
appAccess.Application.Visible = false
Screen.MousePointer = vbHourglass
strFileName = strCurrentYear & strCurrentMonth & Format(CStr(ArrayID(i)), "00000") & ".mdb"
'check if exists and creates the mdb file with name = "yyyymmID"
If Dir(App.Path & "\" & strFileName) <> "" then
Kill App.Path & "\" & strFileName
else
appAccess.NewCurrentDatabase App.Path & "\" & strFileName
End If
'get Database object variable
set objCurrentDB = appAccess.CurrentDb
'Create new table with name = "Customer"
set objCurrentTableDef = objCurrentDB.CreateTableDef("Customer")
'Create fields in new table
for j = 0 to rsCurrentCustomer.Fields.Count - 1
set CurrentField = objCurrentTableDef.CreateField(rsCurrentCustomer.Fields(j).Name, lngDB_Text, intFieldLength)
'Append Field
objCurrentTableDef.Fields.Append CurrentField
next j




Michael Vlastos
Automation Engineer
Company SouthGate Hellas SA
Development Department
Athens, Greece