Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Other Forums
 MS Access
 Alternative to Dlookup

Author  Topic 

djbomb95
Starting Member

9 Posts

Posted - 2012-09-08 : 03:23:18
Ok, I have a perfectly fine SQL query, and it does exactly what I want it to do. This is it below.

SELECT Sum(Price) AS TotalPrice
FROM PizzaOrder
WHERE PizzaOrder.PizzaID In (SELECT PizzaID
FROM PizzaOrder
WHERE OrderID = 89);

My issue arises when I come accross to vba, trying to get the value that this query would return into a textbox. The way I've translated it goes as follows:

txtPrice = DSum("Price", "PizzaOrder", "PizzaID IN " & DLookup("PizzaID", "PizzaOrder", "OrderID = " & txtOrderID & "") & "")

txtPrice is the name of the textbox. I've used a dsum() to replace the Sum() in sql, and my main need is to find an alternative to the "Where... In (Subquery)" syntax. Dlookup only returns the first value, but I am sure I will require more than one value to be returned. Any help would be greaty appreciated. Thanks.

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-09-08 : 07:01:05
Duplicate of http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=178647

People who manage this forum advise against posting the same question to more than one thread/forum - fragments replies, wastes peoples time etc.
Go to Top of Page
   

- Advertisement -