Jul 20, 2006 #1 ITheadache IS-IT--Management Joined Jun 13, 2006 Messages 45 Location US Is there a way to add all the rows in column without needed to use a loop that goes through each record individually?
Is there a way to add all the rows in column without needed to use a loop that goes through each record individually?
Jul 20, 2006 #2 jebry Programmer Joined Aug 6, 2001 Messages 3,006 Location US Hi! Since you asked this question in the Forms forum I would recommend setting the control source of a text box to =DSum("YourField", "YourTable") If you need code to do this you can use a query: Dim rst = DAO.Recordset Dim strSQL = String strSQL = "Select Sum(YourField) As Total From YourTable" Set rst = CurrentDb.OpenRecordset(strSQL) then you can access the total using rst.Total hth Jeff Bridgham Purdue University Graduate School Data Analyst Upvote 0 Downvote
Hi! Since you asked this question in the Forms forum I would recommend setting the control source of a text box to =DSum("YourField", "YourTable") If you need code to do this you can use a query: Dim rst = DAO.Recordset Dim strSQL = String strSQL = "Select Sum(YourField) As Total From YourTable" Set rst = CurrentDb.OpenRecordset(strSQL) then you can access the total using rst.Total hth Jeff Bridgham Purdue University Graduate School Data Analyst