Can you post the SQL of the query that is giving you this error?Hi guys, i have done the modifications, as far as my basic knowledge makes me believe, correctly. i now receieve the error
"Query input must contain atleast one table or query."
Any ideas?
INSERT INTO TAble ( Field1, Field2 )
SELECT TOP 1 Table1name.field1, Table1name.field2
FROM Table1name
ORDER BY Table1name.field1;
Well it's your code so it's up to to you. Since there no IIF in the query that is erroring I am not sure what they have to do with it.Hi the code works fine before i inputted the iif statements, and started using the QryPrices instead of the raw databases. so i dont think its anythin up with the format which it has been written.
hey there are at least 2 iif's in the query so not sure what you mean by
"Since there no IIf in the query"
??
The iffs are needed to either look at one number or look at another, depending on wat the value of "Use_fixed" is. The code is based on some which is already in use. which works perfectly fine. but i need to include these iifs etc. and thats when it stops working and comin up witht that error.
queryString2 = ""
queryString2 = queryString2 & " INSERT INTO markup SELECT TOP 1 JDE_Customer_No AS [JDE Customer No], "
queryString2 = queryString2 & " Custom2.Customer_Name AS [Customer Name], "
queryString2 = queryString2 & " part.id AS Part, "
queryString2 = queryString2 & " price_factor.use_fixed_priced AS [Use_fixed], "
queryString2 = queryString2 & " iif(Use_fixed = '1',QryPrices.FixedPrice,QryPrice.BasePrice) AS [Base_Price] "
queryString2 = queryString2 & " price_factor.fixed_price_factor AS Fixed_Factor, "
queryString2 = queryString2 & " price_factor.factor AS [Factor], "
queryString2 = queryString2 & " QryPrices.QuantityRequired AS [Price Break], "
queryString2 = queryString2 & " part_select.quantity AS [Quantity Required], "
queryString2 = queryString2 & " part.unit_id As [Unit], "
[COLOR="Red"]queryString2 = queryString2 & " iif(Use_fixed ='1' "
queryString2 = queryString2 & " ,(price_factor.fixed_price_factor*(QryPrices.FixedPrice" & conversionRequired & ")) "
queryString2 = queryString2 & " ,(price_factor.factor *( QryPrices.BasePrice" & conversionRequired & ")) AS Price, " [/COLOR]
queryString2 = queryString2 & " part_select.BOM, " & _
queryString2 = queryString2 & " part_select.BOMName, " & _
queryString2 = queryString2 & " part_select.description As [BOM Description], "
queryString2 = queryString2 & " part_select.[BOM Seq] As [BOM Seq], "
queryString2 = queryString2 & " part_select.RS1, "
queryString2 = queryString2 & " part_select.RS2, "
queryString2 = queryString2 & " part_select.RS3, "
queryString2 = queryString2 & " part_select.info, "
queryString2 = queryString2 & " part_select.Error, "
queryString2 = queryString2 & " part.lead_time As [Lead Time], "
[COLOR="red"]queryString2 = queryString2 & ShipleyNorwalkStock & " As [Stock] " [/COLOR]
queryString2 = queryString2 & " FROM part_select, part, QryPrices, price_factor, Custom2, CurrencyConUSD "
queryString2 = queryString2 & " WHERE part.id = part_select.part "
queryString2 = queryString2 & " AND QryPrices.ID=part.id "
queryString2 = queryString2 & " AND Custom2.JDE_Price_Group=price_factor.customer_grou p "
queryString2 = queryString2 & " AND price_factor.part_group=part." & PriceGroup & _
queryString2 = queryString2 & " AND QryPrices.Nationality= " & nationality & _
queryString2 = queryString2 & " AND Custom2.Customer_Name = " & "'" & CustomerSelection & "'" & _
queryString2 = queryString2 & " AND part.id = " & "'" & select_part_rst!part & "'" & _
queryString2 = queryString2 & " AND QryPrices.QuantityRequired <= part_select.quantity " & _
queryString2 = queryString2 & " AND part_select.quantity = " & select_part_rst!quantity & _
queryString2 = queryString2 & " AND part_select.BOM = " & "'" & select_part_rst!BOM & "'" & _
queryString2 = queryString2 & " AND part_select.[BOM Seq] = " & select_part_rst![BOM Seq] & _
queryString2 = queryString2 & " ORDER BY QryPrices.QuantityRequired DESC;"
But not as readable as Namliam made it. Try using the Code directive ie Code enclosed by [ and ] and ended with /CODE the same way. It really makes code much easier to read when your eyesight is NOT brilliant.Here is all my code... in readable format lol
Easy copy paste huh??Hey thanks, I have now changed my code to make it more readable!
n the new code, and now i come up with a type mismatch error, and i have found that it occurs in these lines;
queryString2 = queryString2 & " part_select.BOM, " & _
queryString2 = queryString2 & " part_select.BOMName, " & _
queryString2 = queryString2 & " part_select.description As [BOM Description], "
queryString2 = ""
queryString2 = queryString2 & " INSERT INTO markup SELECT TOP 1 JDE_Customer_No AS [JDE Customer No], "
queryString2 = queryString2 & " Custom2.Customer_Name AS [Customer Name], "
queryString2 = queryString2 & " part.id AS Part, "
queryString2 = queryString2 & " price_factor.use_fixed_priced AS [Use_fixed], "
queryString2 = queryString2 & " iif(Use_fixed = '1',QryPrices.FixedPrice,QryPrice.BasePrice) AS [Base_Price] "
queryString2 = queryString2 & " price_factor.fixed_price_factor AS Fixed_Factor, "
queryString2 = queryString2 & " price_factor.factor AS [Factor], "
queryString2 = queryString2 & " QryPrices.QuantityRequired AS [Price Break], "
queryString2 = queryString2 & " part_select.quantity AS [Quantity Required], "
queryString2 = queryString2 & " part.unit_id As [Unit], "
queryString2 = queryString2 & " iif(Use_fixed ='1' "
queryString2 = queryString2 & " ,(price_factor.fixed_price_factor*(QryPrices.FixedPrice" & conversionRequired & ")) "
queryString2 = queryString2 & " ,(price_factor.factor *( QryPrices.BasePrice" & conversionRequired & ")) AS Price, "
queryString2 = queryString2 & " part_select.BOM, "
queryString2 = queryString2 & " part_select.BOMName, "
queryString2 = queryString2 & " part_select.description As [BOM Description], "
queryString2 = queryString2 & " part_select.[BOM Seq] As [BOM Seq], "
queryString2 = queryString2 & " part_select.RS1, "
queryString2 = queryString2 & " part_select.RS2, "
queryString2 = queryString2 & " part_select.RS3, "
queryString2 = queryString2 & " part_select.info, "
queryString2 = queryString2 & " part_select.Error, "
queryString2 = queryString2 & " part.lead_time As [Lead Time], "
queryString2 = queryString2 & ShipleyNorwalkStock & " As [Stock] "
queryString2 = queryString2 & " FROM part_select, part, QryPrices, price_factor, Custom2, CurrencyConUSD "
queryString2 = queryString2 & " WHERE part.id = part_select.part "
queryString2 = queryString2 & " AND QryPrices.ID=part.id "
queryString2 = queryString2 & " AND Custom2.JDE_Price_Group=price_factor.customer_group "
queryString2 = queryString2 & " AND price_factor.part_group=part." & PriceGroup
queryString2 = queryString2 & " AND QryPrices.Nationality= " & nationality
queryString2 = queryString2 & " AND Custom2.Customer_Name = " & "'" & CustomerSelection & "'"
queryString2 = queryString2 & " AND part.id = " & "'" & select_part_rst!part & "'"
queryString2 = queryString2 & " AND QryPrices.QuantityRequired <= part_select.quantity "
queryString2 = queryString2 & " AND part_select.quantity = " & select_part_rst!quantity
queryString2 = queryString2 & " AND part_select.BOM = " & "'" & select_part_rst!BOM & "'"
queryString2 = queryString2 & " AND part_select.[BOM Seq] = " & select_part_rst![BOM Seq]
queryString2 = queryString2 & " ORDER BY QryPrices.QuantityRequired DESC;"
Also, with the lines u marked in red, what is wrong with;
queryString2 = queryString2 & ShipleyNorwalkStock & " As [Stock] "
Usually there should be a comma at the end of the line but this is the line before the FROM.
It has nothing to do with the comma or anything it was just a remark saying IF it is a text field you have a problem...MY PREVIOUS POST said:The second MAY not be a problem IF this is an numeric field. If it is a Character string you need to enclose that field with qoutes.
Stuffing, well... that is like "putting in".ont know the difference between "stuffing" in a number and a string... is this for example Number = 1, String = [String] ? or wat?
This is exactly what I am driving at. It is NOT numeric... the '1' makes it a string not a number. If Use_Fixed is a number it should just read 1 without the quotes!Use_Fixed is a column name which should have a numerical value (either a 1 or a 0).
I am not saying you should change it now, I am saying you shouldnt use it if you have the chance.... In an excisting app you are not going to be wanting to go back and change stuff like this.And i didnt create any of the tables or anythin, they wer already like that, and this thing is far too big to start messing about with the column names.
Sorry i dont know wat u mean