tags:

views:

187

answers:

4

Hi all. I have simple query, but when I'm trying to execute this query I'm getting error: Query input must contain at least one table or query. (Error 3067)

Query: INSERT INTO FV_Ko ( FvId, OldPriceNetto ) SELECT [PFvId], (SELECT FV.PriceNetto1 FROM FV WHERE FV.FVnr = '123');

Thanks in advance

+1  A: 

The subquery is OK, but you aren't saying where PFvID is coming from. Your INSERT should be something like this:

INSERT INTO FV_Ko ( FvId, OldPriceNetto ) 
SELECT AnotherTable.PFvId, 
(SELECT FV.PriceNetto1 FROM FV WHERE FV.FVnr = '123') FROM AnotherTable
hawbsl
[PFvId] is a parameter passed from VBA script, not from another table: that's the problem. Any ideas how to pass parameters for that querry?
dario
A: 
...   
SELECT [PFvId], --> you should define a FROM table at end of the query
(SELECT FV.PriceNetto1 FROM FV WHERE FV.FVnr = '123');
Nick D
+2  A: 

This should work - it should ask you for [PFvId]

INSERT INTO FV_Ko ( FvId, OldPriceNetto ) 
SELECT [PFvId], FV.PriceNetto1 FROM FV WHERE FV.FVnr = '123';
DJ
A: 

If PFvld is a parameter and the query (MyQuery) is saved (part of the MSAccess database), then you should be able to do:

Dim qdf As DAO.QueryDef
Set qdf = db.QueryDefs("MyQuery")
qdf.Parameters("[PFvld]") = myValue

If you compose the query on the fly and execute it, then you might just specify a value when composing the SQL code instead of a parameter (not that it is a better solution though).

van
Its not true, becasue when I'm executing that querry in that way Im getting error. The same when Im opening querry from Access.
dario
when you have a query with a parameter and you open it directly in MSAccess (double-click or menu "Open"), it should bring little dialog box asking you to enter the parameter. Does it? If it does not, then MSAccess does not think it is a parameter, but rather some field etc. But DJ's answer is also the correct way to compose the SQL.
van