Home All Groups Group Topic Archive Search About

How to add date in access database

Author
27 Feb 2007 1:30 PM
Tony
I am trying this:
SQL = "INSERT INTO GradeList (Date) Values(#01-01-2007#)"

I get message "Syntax error in Insert statement".

How to add date field in access database?

Author
27 Feb 2007 1:46 PM
Bob Lehmann
By enclosing Date in square brackets or renaming the column not using a
reserved word.

SQL = "INSERT INTO GradeList ([Date]) Values(#01-01-2007#)"

SQL = "INSERT INTO GradeList (the_Date) Values(#01-01-2007#)"

Bob Lehmann


Show quote
"Tony" <tonya***@hotmail.com> wrote in message
news:es1avr$qor$1@magcargo.vodatel.hr...
> I am trying this:
> SQL = "INSERT INTO GradeList (Date) Values(#01-01-2007#)"
>
> I get message "Syntax error in Insert statement".
>
> How to add date field in access database?
>
>
>
>
Author
27 Feb 2007 2:08 PM
Paul Clement
On Tue, 27 Feb 2007 14:30:50 +0100, "Tony" <tonya***@hotmail.com> wrote:

¤ I am trying this:
¤ SQL = "INSERT INTO GradeList (Date) Values(#01-01-2007#)"
¤
¤ I get message "Syntax error in Insert statement".
¤
¤ How to add date field in access database?

The keyword Date is reserved (it's a function). Use a different name for your column.


Paul
~~~~
Microsoft MVP (Visual Basic)
Author
27 Feb 2007 3:38 PM
Mark Rae
"Tony" <tonya***@hotmail.com> wrote in message
news:es1avr$qor$1@magcargo.vodatel.hr...

> SQL = "INSERT INTO GradeList (Date) Values(#01-01-2007#)"
>
> I get message "Syntax error in Insert statement".

Yes - that's because in Access the word 'Date' is what is known as a
reserved word - in this particular case, because Date is an Access
function...

> How to add date field in access database?

The "correct" way is, to rename the column to something which isn't a
reserved word...

The "workaround" is to enclose the reserved word in square brackets...

I'd advise you to choose the first option, unless you are unable to change
the database schema...
Author
27 Feb 2007 10:29 PM
Ignacio Machin ( .NET/ C# MVP )
Hi,

First of all there is no need to post to so many groups at the same time.

Regarding your problem, Date is a reserved word, you have to refer to it as
[Date]
Additionally I would suggest you to use parametered queries.

Show quote
"Tony" <tonya***@hotmail.com> wrote in message
news:es1avr$qor$1@magcargo.vodatel.hr...
>I am trying this:
> SQL = "INSERT INTO GradeList (Date) Values(#01-01-2007#)"
>
> I get message "Syntax error in Insert statement".
>
> How to add date field in access database?
>
>
>
>

AddThis Social Bookmark Button