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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DoCmd.RunSQL statement syntax error.

Status
Not open for further replies.

MICKI0220

IS-IT--Management
Jul 20, 2004
337
0
0
US
Can someone tell me what the syntax error is in this code?

DoCmd.RunSQL ("INSERT INTO tbl_ats_Comm_Draw_Hist ( [Key], Cust_ID, Inv_Num, Tran_Type, Inv_Date, Inv_Amt, Sls_RepID )SELECT ARTAP.Seq_no, ARTAP.CustID, ARTAP.InvNum, ARTAP.TranType, ARTAP.Date, ARTAP.Amount, ARTAP.Rep_1)FROM ARTAP WHERE ((ARTAP.TranType)="L") AND ((ARTAP.Contract_type)="B"))


This is in a command buttons code.

Thank you.
 
see prentises in red

DoCmd.RunSQL ("INSERT INTO tbl_ats_Comm_Draw_Hist ( [Key], Cust_ID, Inv_Num, Tran_Type, Inv_Date, Inv_Amt, Sls_RepID )SELECT ARTAP.Seq_no, ARTAP.CustID, ARTAP.InvNum, ARTAP.TranType, ARTAP.Date, ARTAP.Amount, ARTAP.Rep_1)FROM ARTAP WHERE ((ARTAP.TranType)="L") AND ((ARTAP.Contract_type)="B"))

 
Still comes up with this error, highlighting the "L" criteria in Where.

"Compile Error"
"Expected: list separator or )
 
How are ya MICKI0220 . . .

See missing spaces in [red]red[/red] and remove last closing parenthese.
Code:
[blue]DoCmd.RunSQL ("INSERT INTO tbl_ats_Comm_Draw_Hist ( [Key], Cust_ID, Inv_Num, Tran_Type, Inv_Date, Inv_Amt, Sls_RepID )[COLOR=black red] [/color]SELECT ARTAP.Seq_no, ARTAP.CustID, ARTAP.InvNum, ARTAP.TranType, ARTAP.Date, ARTAP.Amount, ARTAP.Rep_1)[COLOR=black red] [/color]FROM ARTAP WHERE ((ARTAP.TranType)="L") AND ((ARTAP.Contract_type)="B")[COLOR=black red])[/color][/blue]
[blue]Your Thoughts? . . .[/blue]

See Ya! . . . . . .

Be sure to see faq219-2884 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Still issues with internal quotes:
Code:
Dim strSQL as String 'baby steps
strSQL = "INSERT INTO tbl_ats_Comm_Draw_Hist " & _
  "( [Key], Cust_ID, Inv_Num, Tran_Type, Inv_Date, Inv_Amt,  Sls_RepID ) " & _
  "SELECT Seq_no, CustID, InvNum, TranType, [Date], Amount, Rep_1) " & _
  "FROM ARTAP " & _
  "WHERE TranType='L' AND Contract_type ='B'"
debug.Print strSQL
DoCmd.RunSQL strSQL


Duane
Hook'D on Access
MS Access MVP
 
DHOOKOM

I tried that and realized I missed a step. can you look at the attacehed code. It is giving the same error on one of the qualifiers.

strSQL = "INSERT INTO tbl_ats_CommissionWork1 " & _
"( Bill_Type_ID, NumOfMonths, Paid_On, [Key], CustID, InvcNum, InvcDate, InvcAmount, PmtNum, Rep1Id, Rep2Id, dtContractStart_dt, TranType ) " & _
"SELECT tbl_ats_Contract.Bill_Type_ID, tbl_ats_Contract.NumOfMonths, tbl_ats_Contract.Paid_On, ARTAP.Seq_no, ARTAP.CustID, ARTAP.InvNum, ARTAP.Date, ARTAP.Amount, ARTAP.ChkNum, ARTAP.Rep_1, ARTAP.Rep_2, ARTAP.CommStDate, ARTAP.TranType" & _
"FROM ARTAP INNER JOIN tbl_ats_Contract ON ARTAP.Contract_type = tbl_ats_Contract.Bill_Type_ID " & _
"WHERE (tbl_ats_Contract.Paid_On)="B" AND (ARTAP.TranType)="L
 
Never mind. I figured it out. I needed some more spaces at the ends.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top