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

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

djbomb95
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.

sunitabeck
Flowing Fount of Yak Knowledge

5155 Posts

Posted - 09/08/2012 :  07:01:05  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New 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.08 seconds. Powered By: Snitz Forums 2000