Entering data from unbound fields to a table on a button click

  • Thread starter Thread starter FALSE_EMAIL
  • Start date Start date
F

FALSE_EMAIL

Hi
I'm stuck, I am trying to copy data from a Form to a table when a button is
used,

I've tried this code but it comes up with an error, can anybody help

CurrentDb.Execute _
"INSERT INTO JAP_audits (Date, Num_audits, Shift) " & _
"VALUES('" & Aud_date & ", '" & Audits & ",'" & Shift & ", ')",
_
dbFailOnError

the Table is Called "JAP_audits" with fields called

Date
Audits
Shift

Thanks in advance

Kev
 
Hi,
The important thing is the data type of your fields.
Dates must be delimited with the # sign, stings with quotes
and number require no delimiters.
What error does it give you? Try using the # sound with Aud_date.

Also, it's always better to assign the string to a variable and Debug.Print it
because the syntax error is usually very obvious.

So...

Dim strSql as String

strSql = "INSERT INTO JAP_audits (Date, Num_audits, Shift) " & _
"VALUES(#" & Aud_date & "#, '" & Audits & "','" & Shift & "')"

Debug.Print strSql
 
Back
Top