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
 General SQL Server Forums
 New to SQL Server Programming
 Problem in Query and DSUM function
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

simplefahad2005
Starting Member

Pakistan
2 Posts

Posted - 07/23/2012 :  01:11:44  Show Profile  Reply with Quote
Hi All,
I am using this query regarding stock card in my application but it is giving error undefined dsum expression. please help me in this regards. Thanks in Advance.

Query is mentioned below.

My query is below kindly help me.
Thanks in advance.

SELECT Stock_Card.StockCardID AS StockCardIDAlias, Stock_Card.StockID AS StockIDAlias, Stocks.Stock, Stock_Card.DateInsert, Stock_Card.ID, Stock_Card.Type, Stock_Card.RefNo1, Stock_Card.Pieces1, Stock_Card.Cost, [Stock_Card]![Cost]*[Pieces1] AS PurchaseAmount, Vendors.Company AS vendor, Stock_Card.RefNo2, Stock_Card.Pieces2, Stock_Card.SalesPrice, [Stock_Card]![SalesPrice]*[Pieces2] AS SalesAmount, Clients.Company AS client, Stock_Card.ICode,
DSum("[Pieces1]-[Pieces2]","Stock_Card","[StockCardID] <" & [StockCardIDAlias] & " And [StockID] = " & [StockIDAlias] & "") AS Previous, DSum("[Pieces1]-[Pieces2]","Stock_Card","[StockCardID] <=" & [StockCardIDAlias] & " And [StockID] = " & [StockIDAlias] & "") AS [On Hand]
FROM Clients RIGHT JOIN (Vendors RIGHT JOIN (Stock_Card LEFT JOIN Stocks ON Stock_Card.StockID = Stocks.StockID) ON Vendors.VendorId = Stock_Card.VendorID) ON Clients.ClientID = Stock_Card.ClientID;

Muhammad Fahad

sunitabeck
Flowing Fount of Yak Knowledge

5152 Posts

Posted - 07/23/2012 :  07:12:21  Show Profile  Reply with Quote
Are you trying to compose a query in your client application to be sent to a SQL Server? The syntax doesn't look like it is SQL - for example, this:
	[Stock_Card]![Cost] * [Pieces1] AS PurchaseAmount,
That aside, what are you trying to calculate in DSum? Are you trying to aggregate some type of stock on hand? If you can write the forumla that you are trying to implement, there are many people on this forum who would be able to suggest the right way to do it.

(Assuming you are using SQL Server. If you are using another RDBMS, it would be better to ask in a forum specific to that system, or in a more generalized forum such as dbforums.com).
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
47157 Posts

Posted - 07/23/2012 :  10:19:13  Show Profile  Reply with Quote
is DSUM a user defined function?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

simplefahad2005
Starting Member

Pakistan
2 Posts

Posted - 07/27/2012 :  02:28:07  Show Profile  Reply with Quote
No it is access function. I didnot use sql server am trying to do it in access.

Muhammad Fahad
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
47157 Posts

Posted - 07/27/2012 :  02:34:20  Show Profile  Reply with Quote
quote:
Originally posted by simplefahad2005

No it is access function. I didnot use sql server am trying to do it in access.

Muhammad Fahad


then you should have posted this in Access forums

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

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.06 seconds. Powered By: Snitz Forums 2000