Solved

insert into troubles

Posted on 2013-02-01
3
208 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
3 Comments
 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
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
Comment Utility
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
Comment Utility
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

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

743 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now