Help with a simple append query

J

Joe Cilinceon

Access 2000 with this simple append query to add a record to a letter sent
table.


strSQL = "INSERT INTO tblTenantLetters ( CustNo, PrintDate, LetterType ) " &
_
"VALUES ( " & Me.CustNo & ", #" & Date & "#, 3 ) ;"

I use almost the exact same syntax on a much larger append query without
problem. now I get not valid SQL

I have even tried to change it as below:

strSQL = "INSERT INTO tblTenantLetters ( CustNo, PrintDate, LetterType ) "
strSQL = strSQL & "VALUES ( "
strSQL = strSQL & Me.CustNo & ", #"
strSQL = strSQL & Date & "#, 3 ) ;"
 
J

John Spencer (MVP)

Are you getting an error message?

Is CustNo a text field? If so, try

"VALUES(""" & me.CustNo & """, #" & Date() & "#, 3)"
 
J

Joe Cilinceon

I got it with the method below

strSQL = "INSERT INTO tblTenantLetters ( CustNo, PrintDate, LetterType,
[Note] )" & _
" SELECT " & [CustNo] & " AS CustNo, #" & Date & "# AS
PrintDate, " & _
"3 AS LetterType, '" & strNote & "' As [Note] ;"

Still don't know why it didn't work but got the one above to work. Thanks
for responding John.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top