The only way I know to do this is to use VBA to loop through the fields
on
the table and put the data into a work table. You can paste the
following
code into a VBA module, save it, and call the code to populate the table.
.
You will have to build the table.
Public Sub sFrequencyCount(strTableName As String)
'CODE is not tested, but the syntax should be correct.
Dim dbAny As DAO.Database
Dim strSQL As String
Dim i As Integer
Dim strFieldName As String
'Requires a table named tblFreqCount with fields
' TableName (text -64)
' FieldName (text -64)
' FieldValue (text - 255)
' FieldCount (Number - Long)
Set dbAny = CurrentDb()
'Optional line to delete all records in tblFreqCount
dbAny.Execute "DELETE FROM tblFreqCount"
'Optional line to delete just records for specified table
dbAny.Execute "DELETE FROM tblFreqCount" & _
"WHERE tableName =""" & strTableName & """", dbFailOnError
For i = 0 To dbAny.TableDefs(strTableName).Fields.Count - 1
strFieldName = _
dbAny.TableDefs(strTableName).Fields(i).Name
strSQL = "Insert Into tblFreqCount " & _
"(TableName, FieldName, FieldValue, FieldCount)" & _
" SELECT """ & strTableName & _
""", """ & strFieldName & """" & _
", [" & strFieldName & "]" & _
", Count([" & strFieldName & "]) as theCount" & _
" FROM [" & strTableName & "] " & _
" GROUP BY [" & strFieldName & " ]"
dbAny.Execute strSQL, dbFailOnError
Next i
End Sub
--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
Hi-
I'm trying to find a simpler way to run a frequency table for all
fields.
Right now I'm using the SQL code below to run a select query, but it
only
works one field at a time. I have 200 fields and would like to run all
200
distributions at once. I have tried looking in the help documentation
but
have not had success. Any ideas?
SELECT FIELD, Count(*) AS Frequency
FROM
WHERE ID Is Not Null
GROUP BY FIELD
ORDER BY FIELD;
Thanks,
Nicole