dmorgan20
dmorgan20

Reputation: 363

SQL to insert to a table

I am using the below SQL to try and put content in a textbox, to a different table. It was working until I added the text 43, and text 109 section

DoCmd.RunSQL "INSERT INTO tbl_EmailsSent (AccountNumber, Email1, ID, LoggedUser, LoggedDate) 
    VALUES (' " & Me.Text8 & "', 'Sent', ' " & Me.Text109 & ", ' " & me.Text43 "');

Can you see the mistake? Because I cant unfortunately

Upvotes: 0

Views: 42

Answers (1)

Gustav
Gustav

Reputation: 55981

Yes, it's the date and the spaces ans missing quotes:

DoCmd.RunSQL "INSERT INTO tbl_EmailsSent (AccountNumber, Email1, ID, LoggedUser, LoggedDate) 
VALUES ('" & Me.Text8 & "', 'Sent', '" & Me.Text109 & "', #" & Format(Me!Text43.Value, "yyyy\/mm\/dd") & "#);"

No ID:

DoCmd.RunSQL "INSERT INTO tbl_EmailsSent (AccountNumber, Email1, LoggedUser, LoggedDate) 
VALUES ('" & Me.Text8 & "', 'Sent', '" & Me.Text109 & "', #" & Format(Me!Text43.Value, "yyyy\/mm\/dd") & "#);"

Upvotes: 1

Related Questions