Trying to create a field

F

Fia

I'am trying to create a field from a field I already have in a table. The
field I have is called Date and has the type dbDate and when you look at the
field in designview it has the property Format put to "short date".
But when I'm using the code below and looks at the new field called Date1 in
designview it doesn't have anything put in the property Format. I hope the
property is called the same in the english version. I'm using Access 97 in
Swedish.

Dim tblDef As DAO.TableDef
Dim DB As DAO.Database
Dim prp As DAO.Property
Dim i As Integer
Dim f, f1 As Field
Set DB = OpenDatabase(CurrentDb.Name)
Set tblDef = DB.TableDefs("Table")
set f=tbldef.Fields("Date")
with f
Set f1 = tblDef.CreateField("Date1", f.Type, f.Size)
f1.Attributes = f.Attributes
i = 0
For Each prp In f.Properties
On Error Resume Next
If prp.Name <> "Name" And prp.Name <> "Type" And
prp.Name <> "Attributes" And prp.Name <> "Size" Then
f1.Properties(i) = prp.Value
End If
On Error GoTo 0
i = i + 1
Next
tblDef.Fields.Append f1
end with

Thank's

Fia
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top