Short Date from text field into sql statement ms access

strSQLzm1a = "INSERT INTO dbGrafikTest (imieNazwisko, numerTelefonu, zmiana, praca, data) VALUES ('" & Me!listZM1a.Column(0) & "', '" & Me!listZM1a.Column(1) & "', 'zm1', 'automatyk', #" & Me!txtData & "#);"

This SQL statement returns error:

Syntax error in date in query expression '#21.03.2016'.

txtData is a text field and its formated as Short Date. I'm searching googles to find the answer for where i made a syntax error and i really dont understand where i did it.

Database column data is formated as Date/Time as well.

Answers


The db engine can't cope with 21.03.2016 as a date literal.

Format it in a way which the db engine can use.

Change this ...

& Me!txtData &

to this ...

& Format(Me!txtData, "yyyy-m-d") &

Or you could use a parameter query, and then supply the needed Date/Time value without format concerns.


Need Your Help

Performance variability of C++ pure virtual function calls

c++ performance polymorphism virtual-functions

I had to design and develop a C++ module which will be used in a real time environment (it will be run on a modern multi-core PC). When I designed it I created C++ interfaces (classes with only pure

Drag block element from one point to another inside ContentEditable div

javascript jquery html5 drag-and-drop contenteditable

I'm needing to let users drag an element inside a contenteditable div to another point in the text. The item that needs to be movable is set to ContentEditable=false.