Data Type

  • Thread starter Thread starter Paul
  • Start date Start date
P

Paul

Hi!
In my database i have a table with a field named "Date
end".
It's a table that i change many times every month, and
it's imported from Excel
For default the data type of this field is set like text
I need to set it like date, i want to change it
automatically with Dao.
Someone can help me to do it?

Thanks in advance
 
In my database i have a table with a field named "Date
end".
It's a table that i change many times every month, and
it's imported from Excel

Importing from Excel is a pain; since Excel doesn't have "strong data
typing", Access must guess, and as you have found often guesses wrong.

I'd suggest not importing into a new table at all. Instead, create a
permanent table with the desired datatypes; in your code, run a Delete
query to empty this table, Link to the spreadsheet, and run an Append
query to move the data into your table.

In either case (deleting and recreating tables, or emptying and
refilling them) you'll need to Compact your database regularly, since
the deleted space will not be recovered!
 
From Access 2003 Help:

"Type Property
Sets or returns a value that indicates the operational type or data type of
an object.

Settings and Return Values

The setting or return value is a constant that indicates an operational or
data type. For a Field or Property object, this property is read/write until
the object is appended to a collection or to another object, after which
it's read-only. ..."

Thus, you cannot _change_ it.

What you can do is to Create a new Field of the type dbDate, append it to
the Fields collection, and set the values of that Field from the Text field
using the built-in CDate function. Then you can, if disk space is at a
premium (usually isn't, these days), delete the original text field. This is
what goes on "behind the scenes" when you change a field's type in table
design view.

Larry Linson
Microsoft Access MVP
 
Back
Top