Data Type Assistance

G

gb_S49

I have a field which is currently Date/Time Data type.
How can I change it to Date / Time but with a default text value if blank or
new records to "Present" ?
 
O

Ofer Cohen

Open the table in design view,
Set the Default value of that field to
Date ()

If you want the current date, or
Now()

To current date and current time

That won't update the records that already have Null in them for that
you'll need to run an update query

UPDATE TableName SET TableName.DateFieldName = Now()
WHERE TableName.DateFieldName Is Null

Or, if you don't want the time
UPDATE TableName SET TableName.DateFieldName = Date()
WHERE TableName.DateFieldName Is Null
 
G

gb_S49

Thanks But perhaps i was not very clear.
I want the users to enter the date value (in dd/mm/yy fromat) when creating
a record.
If the field is blank I want it just to display the word "Present" (text)
 
O

Ofer Cohen

In that case the you need to change the field type to text, and change the
default to "present", I would suggest leaving the field as Date field, and
then change it to present when displayed in a report using the NZ function to
replace Null with "present"

Select TableName.*, Nz(DateFieldName, "Present") As NewDateField
From TableName
 
R

Ron2006

That is particularly true if you ever want to sort by that field.

A TEXT field containing a text date string will NOT sort as a true
date.

For example with the format you are using for entering the information
all of the day 1 for all months for all years would sort to the top if
sorting ascending. Keep it as a date field if you want to sort by
date.

Ron
 
Top