Inserting Date syntax

  • Thread starter gmazza via AccessMonster.com
  • Start date
G

gmazza via AccessMonster.com

Hi there,
I am having a problem inserting a Date field into a table, keep getting a
syntax error, any ideas, I've been trying and can't quite figure it out.

sSql = "INSERT INTO PatientData ( PatientId, ClinicalTrialId, VisitDate)
" & _
"VALUES(" & _
"'" & Me.PatientId & "', " & _
"'" & GetActiveStudy() & "', " &
_
"'" & Format(Me.VisitDate, "\#mm\
/dd\/yyyy\#") & ");"
 
J

Jeff Boyce

Why are you using the Format() function on your date field? That is, what
do you want it to do?

I thought you just wanted the date in that date field to get inserted into a
date/time-datatype field...

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
M

Marshall Barton

gmazza said:
Hi there,
I am having a problem inserting a Date field into a table, keep getting a
syntax error, any ideas, I've been trying and can't quite figure it out.

sSql = "INSERT INTO PatientData ( PatientId, ClinicalTrialId, VisitDate)
" & _
"VALUES(" & _
"'" & Me.PatientId & "', " & _
"'" & GetActiveStudy() & "', " &
_
"'" & Format(Me.VisitDate, "\#mm\
/dd\/yyyy\#") & ");"


What you have is fine except you put an extra "'" in fornt
of Format

If your PatientId and ClinicalTrialId fields are number type
fields, then you have the same problem (along with an extra
' before the comma) with these fields.
 

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