QueryDef with Where statement

TimTDP

Registered User.
Local time
Today, 21:32
Joined
Oct 24, 2008
Messages
213
I am new at QueryDefs!

How do I include a where statement in a QueryDef? If I run the code below:

Code:
Set qdf = CurrentDb.QueryDefs("qrySupplierOrderExcelCodeQuantity where SupplierPurchaseOrderResaleId = " & intSupplierOrderId)
I get a Run time error 3262 - Item not found in this collection

If I run the code:
Code:
Set qdf = CurrentDb.QueryDefs("qrySupplierOrderExcelCodeQuantity")
It runs fine, but without filtered data

Thanks in advance
 
The bracketed section is the name of the querydef not the SQL of the query.

You can change the SQL of the querydef by modifying its SQL property.
 
do you realy need it as Query def ?

you can create a Query string:
strQRY = "SELECT * FROM [qrySupplierOrderExcelCodeQuantity] where [SupplierPurchaseOrderResaleId] = " & intSupplierOrderId
and run this without the need for query def
 

Users who are viewing this thread

Back
Top Bottom