C
Chris E.
I am trying to "stuff" a text box on a form with the
results of a query. The basic need is to display the last
price that a client paid for a given product. I'm working
in an Order Detail subform. I have been trying to use the
Control Source for the text box I call LastPrice. I have
placed a SELECT statement in the field. The LastPrice
text box displays #name no matter what the select
statement is.
I've tried various versions of the following:
SELECT TOP 1 [OrderDetails].[UnitPrice] FROM
[OrderDetails] INNER JOIN [OrderDetails] ON [Orders].
[OrderID] = [OrderDetails].[OrderID] WHERE [Orders].
[CustomerID] = "the current order record's CustomerID"
AND [OrderDetails].[ProductID] = "the current detail
record ProductID" ORDER BY DESCENDING [Orders].[OrderDate]
Can I add AS LastPrice to the above to load the text box
or will the select do it because of the TOP 1.
What is the prefered syntax for loading a select with
specific data from a currently opened form? Should I use
Me!.CustomerID or is that only for VB? What about
selection criteria which needs data from the form
(CustomerID) and the sub form (ProductID) when ProductID
can have several rows of data.
What happens if there are no records that match the
criteria? What will LastPrice contain?
Thanks for any assistance.
Chris
results of a query. The basic need is to display the last
price that a client paid for a given product. I'm working
in an Order Detail subform. I have been trying to use the
Control Source for the text box I call LastPrice. I have
placed a SELECT statement in the field. The LastPrice
text box displays #name no matter what the select
statement is.
I've tried various versions of the following:
SELECT TOP 1 [OrderDetails].[UnitPrice] FROM
[OrderDetails] INNER JOIN [OrderDetails] ON [Orders].
[OrderID] = [OrderDetails].[OrderID] WHERE [Orders].
[CustomerID] = "the current order record's CustomerID"
AND [OrderDetails].[ProductID] = "the current detail
record ProductID" ORDER BY DESCENDING [Orders].[OrderDate]
Can I add AS LastPrice to the above to load the text box
or will the select do it because of the TOP 1.
What is the prefered syntax for loading a select with
specific data from a currently opened form? Should I use
Me!.CustomerID or is that only for VB? What about
selection criteria which needs data from the form
(CustomerID) and the sub form (ProductID) when ProductID
can have several rows of data.
What happens if there are no records that match the
criteria? What will LastPrice contain?
Thanks for any assistance.
Chris