Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

insert into troubles

Posted on 2013-02-01
3
Medium Priority
?
215 Views
Last Modified: 2013-02-01
I can't seem to get the syntax correct for this query in vba.
Any ideas?

Dim strsql As String
      strsql = "INSERT INTO tbltrad_commandes_FPdetails" & _
      "(trad_commandesID,ContractQuantity,ContractPrice,NegociatedRate,tmpSelect) " & _
      "(SELECT " & Forms![frmtrad_commandes2]![trad_commandesID] & ",ContractQuantity,ContractPrice,NegociatedRate,-1 " & _
"FROM tblTranslationContractPricing WHERE ContractQuantity = " & arr(i) & " AND Active = True)"
0
Comment
Question by:Shawn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 38845097
what is the error?

what Data Type is field ContractQuantity ? , Active ?
0
 
LVL 48

Accepted Solution

by:
Dale Fye earned 2000 total points
ID: 38845102
strsql = "INSERT INTO tbltrad_commandes_FPdetails" _
          & "(trad_commandesID,ContractQuantity,ContractPrice,NegociatedRate,tmpSelect) " _
          & "SELECT " & Forms![frmtrad_commandes2]![trad_commandesID] _
                               & ",ContractQuantity,ContractPrice,NegociatedRate,-1 " _
          & "FROM tblTranslationContractPricing " _
          & "WHERE ContractQuantity = " & arr(i) & " AND Active = -1"

I removed a set of () around the SELECT statement, and did some reformatting (the way I prefer), but I think your main problem was the ( ) around the SELECT statement.
0
 
LVL 1

Author Closing Comment

by:Shawn
ID: 38845114
worked perfectly. thanks for the extra format help.

the only thing I changed was from Active = -1 to Active = True.
For some reason the -1 did not convert well.
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question