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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Register Now and get your question answered!
Save Password
Forgot your Password?

 All Forums
 Other Forums
 MS Access
 Alternative to Dlookup
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

9 Posts

Posted - 09/08/2012 :  03:23:18  Show Profile  Reply with Quote
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.

Flowing Fount of Yak Knowledge

5155 Posts

Posted - 09/08/2012 :  07:01:05  Show Profile  Reply with Quote
Duplicate of

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
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000