2016-12-01 13 views
0

次のSQLを使用して、テキストボックス内のコンテンツを別のテーブルに挿入しようとしています。テキスト43とテキスト109セクションを追加するまでは機能していましたテーブルに挿入するSQL

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

間違いを確認できますか?私は残念ながら

+0

使用 'Debug.Print':[動的SQLをデバッグする方法VBA](http://stackoverflow.com/questions/418960/managing-and-debugging-sql-queries-in-ms-access/1099570#1099570) - いくつかのエラー(余分なスペース、引用符がない)があります。 – Andre

+0

そして、あなたのコントロールに意味のある名前をつけてください。 'Me.txtAccountNumber'は' Me.Text8'よりはるかに読みやすくなります。 – Andre

答えて

1

カントのではい、それは引用符が欠落している日付とスペースのANSません:

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

んID:

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

DoCmd.RunSQL "INSERT INTO tbl_EmailsS​​ent(AccountNumber、Email1、ID、LoggedUser、LoggedDate)VALUES( '"&Me.Text8& "'、 'Sent'、 '"&Me.Text109& "' ''&Me.Text43& "'、#"&Format(Me!Text43.Value、 "yyyy \/mm \/dd")& "#); " – dmorgan20

+0

私はそれを疑う。自動番号。 – Gustav

関連する問題