Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

reporting table def criteria

Status
Not open for further replies.

markhirt

Programmer
Mar 26, 2002
13
US
I need to generate a report that lists all fields and the first value of each field in a report. Any suggestions?
 
hello

I had to do some thing a littl similar see vba below

This prints it to the debug window
you may have a table ready or want to create one each time this is run - how ever you want to do it.


This uses 3 routines

just in case you need data types as well.

Sub Print_tableNames
This just lists all tables in the DB

Each time a non system table is identified it passes
name to this routine

Sub Print_Field_Names(tblname As String)

this provides the data.
Additionally it provides the data type by calling

Function FieldType(intType As Integer) As String
THis one is optional of course.
------------------------------------------------

Sub Print_tableNames()
Dim mydb As Database
Set mydb = CurrentDb
Dim rst As DAO.Recordset, intI As Integer
Dim fld As Field
Dim tdf As TableDef
For Each tdf In mydb.TableDefs
If InStr(1, tdf.Name, "msys") = 0 Then
Print_Field_Names (tdf.Name) ' excludes system tables
Else
End If
Next
End Sub




Sub Print_Field_Names(tblname As String)
Dim mydb As Database
Set mydb = CurrentDb
Dim rst As DAO.Recordset, intI As Integer
Dim fld As Field


Set rst = mydb.OpenRecordset(tblname, dbOpenDynaset)
rst.MoveFirst
For Each fld In rst.Fields

Debug.Print tblname & "," & fld.Name & "," & FieldType(fld.Type) & "," & fld.Size & " , "; fld.Value
Next
End Sub




Function FieldType(intType As Integer) As String

Select Case intType
Case dbBoolean
FieldType = "dbBoolean"
Case dbByte
FieldType = "dbByte"
Case dbInteger
FieldType = "dbInteger"
Case dbLong
FieldType = "dbLong"
Case dbCurrency
FieldType = "dbCurrency"
Case dbSingle
FieldType = "dbSingle"
Case dbDouble
FieldType = "dbDouble"
Case dbDate
FieldType = "dbDate"
Case dbText
FieldType = "dbText"
Case dbLongBinary
FieldType = "dbLongBinary"
Case dbMemo
FieldType = "dbMemo"
Case dbGUID
FieldType = "dbGUID"
End Select

End Function


hope this is ok

regards jo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top