Problem getting dates to enter a date field correctly

D

Dave Reardon

I have a table with a field for dates, which contains four rows. I am
attempting to use the first date to populate a field in a different table,
using an update query written in SQL. The syntax is:
rs.ActiveConnection = DR

rs.Open "AttDatesT"

With rs
rs.MoveFirst
datDate = .Fields("DateId")

MsgBox strDate
strSQL1 = "UPDATE [Students-T] SET [Students-T].Date1 = "
DoCmd.RunSQL strSQL1 & datDate
End With
rs.Close

The message box displays the date correctly, eg 10/02/2010 but when I go to
the field to look at the data in the table it typically displays something
like 00:03:35 I assume it is to do with a date conversion, but I don't seem
to find any reference to this anywhere. Any help very welcome.
 
P

Paolo

Hi Dave Reardon,

you have to enslose your date between hash signs so

DoCmd.RunSQL strSQL1 & "#" & datDate & "#"

HTH Paolo
 

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