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.
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.