Changing the data type of a field using code or macro

  • Thread starter Thread starter ChuckW
  • Start date Start date
C

ChuckW

Hello,

I have a customer table in which contains a field called
birthday. The data type though is text rather than
date. I cannot change the data type though to date for
reasons that would take too long to explain. What I did
was to write a query that extracts the data our of the
customer table and then create a make table and call it
Birthdays. Then I manually changed the field from text
to date. Now I want to automate this. I want to create a
button on a form that runs a macro. The macro would run
the query that extracts the data out of my table, creates
a make table and then changes the data type from text to
date? All without any pop-ups like "You are about to
paste XXX rows into a table..."?

Can anyone help?

Thanks,

Chuck
 
You can use Date: CDate([Birthday]) in the query, this
converts the date to a date. However, if it's invaild,
i.e. blank or not properly formated 04/03 or April 25...
It will just place an Invaild in the field. Then in the
macro you would use SetWarings = False. Or better in the
VBA code of the button put this before Run Query.
DoCmd.SetWarnings False and after the Query but
DoCmd.SetWarnings True.
 
Back
Top