Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Append Statement

Status
Not open for further replies.

end922

Technical User
Apr 17, 2007
59
US
Greetings,

in new territory here. pasted this sql statement from a working append query to VB tried a couple of different things to make it work still getting a compile error.

Appreciate the assistance.

SSQL = "INSERT INTO tblEvents ( BillID, BorID, OpenDate, Status, ClosedDate, Reason," & _
"Type, [Task $] ) SELECT tempBillingTable.Billid, tempBillingTable.BorID, tempBillingTable.BOpenDate," & _
"tblStatus.Status, tempBillingTable.BClosedDate, tblOpenReason.OpenReason, IIf([Billid] Is Not Null,"Billing","") AS Type," & _
"tempBillingTable.BilledAmt FROM (tempBillingTable LEFT JOIN tblStatus ON tempBillingTable.Status = tblStatus.StatusID) LEFT JOIN tblOpenReason ON tempBillingTable.BOpenReason = tblOpenReason.OpenID"
DoCmd.RunSQL SSQL
 
try doing a debug.print of SSQL just before the docmd and see if the results run in a query...

--------------------
Procrastinate Now!
 
You need to change double quotes to single quotes after pasting:

[tt]SSQL = "INSERT INTO tblEvents ( BillID, BorID, OpenDate, Status, ClosedDate, Reason," & _
"Type, [Task $] ) SELECT tempBillingTable.Billid, tempBillingTable.BorID, tempBillingTable.BOpenDate," & _
"tblStatus.Status, tempBillingTable.BClosedDate, tblOpenReason.OpenReason, IIf([Billid] Is Not Null,'Billing','') AS Type," & _
"tempBillingTable.BilledAmt FROM (tempBillingTable LEFT JOIN tblStatus ON tempBillingTable.Status = tblStatus.StatusID) LEFT JOIN tblOpenReason ON tempBillingTable.BOpenReason = tblOpenReason.OpenID"
[/tt]
 
Worked. Thank you! When executed it was pointing at "Billing" on error. I didn't think about the " to '
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top