Re: Is there a way to select all the field NAME by a SQL statement

Tech-Archive recommends: Speed Up your PC by fixing your registry

From: VC (VC_at_discussions.microsoft.com)
Date: 07/10/04


Date: Sat, 10 Jul 2004 06:48:02 -0700

Thanks a lots

"Allen Browne" wrote:

> Function ShowFields(strTable As String)
> Dim db As DAO.Database
> Dim tdf As DAO.TableDef
> Dim fld As DAO.Field
>
> Set db = CurrentDb()
> Set tdf = db.TableDefs(strTable)
> For Each fld In tdf.Fields
> Debug.Print fld.Name, FieldTypeName(fld.Type)
> Next
>
> Set fld = Nothing
> Set tdf = Nothing
> Set db = Nothing
> End Function
>
> Function FieldTypeName(n As Long) As String
> 'Purpose: Converts the numeric results of DAO fieldtype to text.
> 'Note: fld.Type is Integer, but the constants are Long.
> Dim strReturn As String 'Name to return
>
> Select Case n
> Case dbBoolean
> strReturn = "Yes/No" '1
> Case dbByte
> strReturn = "Byte" '2
> Case dbInteger
> strReturn = "Integer" '3
> Case dbLong
> strReturn = "Long Integer" '4
> Case dbCurrency
> strReturn = "Currency" '5
> Case dbSingle
> strReturn = "Single" '6
> Case dbDouble
> strReturn = "Double" '7
> Case dbDate
> strReturn = "Date/Time" '8
> Case dbBinary
> strReturn = "Binary" '9
> Case dbText
> strReturn = "Text" '10
> Case dbLongBinary
> strReturn = "OLE Object" '11
> Case dbMemo
> strReturn = "Memo" '12
> Case dbGUID
> strReturn = "GUID" '15
> Case dbBigInt
> strReturn = "Big Integer" '16
> Case dbVarBinary
> strReturn = "VarBinary" '17
> Case dbChar
> strReturn = "Char" '18
> Case dbNumeric
> strReturn = "Numeric" '19
> Case dbDecimal
> strReturn = "Decimal" '20
> Case dbFloat
> strReturn = dbFloat '21
> Case dbTime
> strReturn = "Time" '22
> Case dbTimeStamp
> strReturn = "Time Stamp" '23
> Case Else
> strReturn = "Field type " & n & "unknown"
> End Select
> FieldTypeName = strReturn
> End Function
>
> --
> Allen Browne - Microsoft MVP. Perth, Western Australia.
> Tips for Access users - http://allenbrowne.com/tips.html
> Reply to group, rather than allenbrowne at mvps dot org.
>
> "VC" <VC@discussions.microsoft.com> wrote in message
> news:6CCE3FF0-1DBF-4D5D-8D2B-92C20E71555B@microsoft.com...
> > Hi Duane,
> > Could u kindly provide me a sample code for that?
> >
> > "Duane Hookom" wrote:
> >
> > > Not in Access. There are lots of code samples that do this.
> > >
> > > --
> > > Duane Hookom
> > > MS Access MVP
> > >
> > >
> > > "VC" <VC@discussions.microsoft.com> wrote in message
> > > news:B0F0DE2F-7596-43AE-A43B-111ABD9ECB6C@microsoft.com...
> > > > I know how to get all the table name by
> > > > SELECT DISTINCT MSysObjects.Name FROM MSysObjects WHERE
> > > (((MSysObjects.Name) Like "tbl*") AND ((MSysObjects.Type)=1));
> > > >
> > > > Is there a way to select all the field NAME by a SQL statement??
>
>
>



Relevant Pages

  • Re: Dynamic list... tougher than it sounds
    ... Dim tdf As DAO.TableDef ... Dim fld As DAO.Field ... Set tdf = db.TableDefs ... Dirk Goldgar, MS Access MVP ...
    (microsoft.public.access.modulesdaovba)
  • Re: How to drop all the indexes of a table
    ... Allen Browne - Microsoft MVP. ... "Thomas" wrote in message ... Dim tdf As DAO.TableDef ... Set tdf = db.TableDefs ...
    (microsoft.public.access.queries)
  • compare two tables using this module?
    ... In the article "Delete Duplicate Records From Access Tables" ... Dim rst2 As DAO.Recordset ... Dim fld As DAO.Field ... Set tdf = DBEngine.TableDefs ...
    (comp.databases.ms-access)
  • compare tables
    ... In the article "Delete Duplicate Records From Access Tables" ... Dim rst2 As DAO.Recordset ... Dim fld As DAO.Field ... Set tdf = DBEngine.TableDefs ...
    (comp.databases.ms-access)
  • Re: Add Index Property To Temp Table
    ... Brendan Reynolds ... Dim tdf As DAO.TableDef ... Dim fld As DAO.Field ... 'Set tdf = db.CreateTableDef ...
    (microsoft.public.access.tablesdbdesign)