Datefield from variable into a datefield in an access b

  • Thread starter Thread starter Cor Ligthert [MVP]
  • Start date Start date
Hello, reidarT,

Try replacing dteDato in your SQL with Format(dteDato, "#yyyy-MM-dd#").

Note that I am recommending using a fixed date format. As I recall,
Access by default uses m/d/y, but it also happily accepts the (far
better) ISO format.

Groetjes,
Randy
 
I use a DateTimePicker to get a date.
I want to add this date into an access table.
I use a variable like
Dim dteDato As Date = Format(Me.txtDato.Value, "Short date")

In the sql-statement I use
INSERT INTO tblToDo ( Dato, Bruker, Utfort, Melding, MeldingFra ) " & _
"SELECT " & dteDato & ", '" & strSaksbehandler & "', -1, '" & strMelding &
"', 'Fra Peres'", con)
....

The date shows as #7/1/2006#, but when I run the sql I get a syntax-error
If I replace the dteDato in the sql with #7/1/2006# it works OK.

reidarT
 
Back
Top