Solved

insert into troubles

Posted on 2013-02-01
3
212 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 47

Accepted Solution

by:
Dale Fye (Access MVP) earned 500 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

735 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