Change Data Type

J

Jonas

Is there a way to change the data type of a variable from text to
date? From what I have been reading, I understand that it is possible
to change the data type of a field but I want to change the data type
of a variable.
 
J

Jonas

Is there a way to change the data type of a variable from text to
date?  From what I have been reading, I understand that it is possible
to change the data type of a field but I want to change the data type
of a variable.

I meant to type string not text.
 
J

JimBurke via AccessMonster.com

What exactly are you trying to accomplish? Per Piet's suggestion, if you need
to convert a string field to a date then use the CDate command. But first
check to make sure it is a valid date using IsDate, e.g.

If IsDate(strField) then
newField = CDate(strField)
Else
do whatever you need to do if it's not a valid date here...
End If

If you're trying to do something else you might want to explain exactly what
it is you need to accomplish.
 
J

Jonas

What exactly are you trying to accomplish? Per Piet's suggestion, if you need
to convert a string field to a date then use the CDate command. But first
check to make sure it is a valid date using IsDate, e.g.

   If IsDate(strField) then
      newField = CDate(strField)
   Else
        do whatever you need to do if it's not a valid date here....
   End If

If you're trying to do something else you might want to explain exactly what
it is you need to accomplish.

All that I needed to do was change the data type to date. It worked.
Thanks for the help.
 

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