B bbwolff Registered User. Local time Today, 09:21 Joined Oct 1, 2013 Messages 116 Mar 2, 2014 #1 How can i get the value that is used most common in one column of the table through vba code?
Isskint Slowly Developing Local time Today, 08:21 Joined Apr 25, 2012 Messages 1,302 Mar 2, 2014 #2 You would need a DMean() function - something Access does not have. Have a look at this link http://perrin.socsci.unc.edu/tips/src/daverages.txt. it lists a DMedian() and a DMode() function EDIT Just a thought, would a TOP 1 query do this?? Code: SELECT TOP 1 Table1.Data FROM Table1 GROUP BY Table1.Data ORDER BY Count(Table1.Data) DESC;
You would need a DMean() function - something Access does not have. Have a look at this link http://perrin.socsci.unc.edu/tips/src/daverages.txt. it lists a DMedian() and a DMode() function EDIT Just a thought, would a TOP 1 query do this?? Code: SELECT TOP 1 Table1.Data FROM Table1 GROUP BY Table1.Data ORDER BY Count(Table1.Data) DESC;
B bbwolff Registered User. Local time Today, 09:21 Joined Oct 1, 2013 Messages 116 Mar 2, 2014 #3 this seems to work Code: Dim rs As DAO.Recordset Dim strSQL As String strSQL = "SELECT tName FROM Table GROUP BY tName ORDER BY Count(table.tName) DESC;" Set rs = CurrentDb.OpenRecordset(strSQL) rs.MoveFirst MsgBox rs!tName
this seems to work Code: Dim rs As DAO.Recordset Dim strSQL As String strSQL = "SELECT tName FROM Table GROUP BY tName ORDER BY Count(table.tName) DESC;" Set rs = CurrentDb.OpenRecordset(strSQL) rs.MoveFirst MsgBox rs!tName