Solved

insert into troubles

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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
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…

626 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