I
Ian Eldred
I have created a query retrieving data from 3 tables:
Invoices
Purchase Orders
Property Details
Here is my query:
SELECT
Invoices.InvoiceID,
Invoices.RelatePO,
IIf([RelatePO]=-1,Format([PONumber],"0000"),"N/A") AS [PO Number],
IIf([RelatePO]=-1,DLookup("[Property Name]","[Property
Details]","[PropertyRef]=" & DLookUp("[PropertyRef]","[Purchase
Orders]", "[PONumber]=" & [PONumber])),
IIf(IsNull(InvoiceProperty]),"Miscellaneous
Invoices",DLookup("[Property Name]","[Property
Details]","[PropertyRef]=" & [InvoiceProperty])) AS [Property Name],
IIf([RelatePO]=-1,DLookUp("[Description]","[Purchase
Orders]","[PONumber]=" & [PONumber]),[InvoiceDescription]) AS
Description,
Invoices.InvoiceDate,
etc...
FROM Invoices;
I know that all those IIF's and DLookup's are very inefficient, but
just don't know how to avoid using them. Any help would be greatly
appreciated.
TIA
Ian
Invoices
Purchase Orders
Property Details
Here is my query:
SELECT
Invoices.InvoiceID,
Invoices.RelatePO,
IIf([RelatePO]=-1,Format([PONumber],"0000"),"N/A") AS [PO Number],
IIf([RelatePO]=-1,DLookup("[Property Name]","[Property
Details]","[PropertyRef]=" & DLookUp("[PropertyRef]","[Purchase
Orders]", "[PONumber]=" & [PONumber])),
IIf(IsNull(InvoiceProperty]),"Miscellaneous
Invoices",DLookup("[Property Name]","[Property
Details]","[PropertyRef]=" & [InvoiceProperty])) AS [Property Name],
IIf([RelatePO]=-1,DLookUp("[Description]","[Purchase
Orders]","[PONumber]=" & [PONumber]),[InvoiceDescription]) AS
Description,
Invoices.InvoiceDate,
etc...
FROM Invoices;
I know that all those IIF's and DLookup's are very inefficient, but
just don't know how to avoid using them. Any help would be greatly
appreciated.
TIA
Ian