Results 1 to 3 of 3

Thread: few questions

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2000
    Location
    Leeds
    Posts
    30
    1)if/how you can find out the data type of a certain column in a DBGrid?
    2)how can you find out which column of a database is the primary key and also which other table in the database this primary key is connected to?

    Any help is much appreciated, thanks Piers

  2. #2
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844
    #1 Field data types
    Code:
        'uses dao 3.5/6
        Dim db As Database
        Dim tb As TableDef
        Dim fld As Field
        
        Set db = DBEngine.OpenDatabase("Nwind2k.mdb")
        
        Set tb = db.TableDefs("Customers")
        
        For Each fld In tb.Fields
            'field data types -- match up with DataTypeEnum members
            Debug.Print fld.Type
        Next fld
    
        db.Close
        
        Set db = Nothing
    #2 -- Table relationship information
    Code:
        Dim db As Database
        Dim rl As Relation
        Dim fld As Field
        
        Set db = DBEngine.OpenDatabase("Nwind2k.mdb")
        
        For Each rl In db.Relations
            Debug.Print "NAME:  " & rl.Name
            Debug.Print "TABLES:  " & rl.Table & " -- " & rl.ForeignTable
            For Each fld In rl.Fields
                Debug.Print "FIELDS:  " & fld.Name & " -- " & fld.ForeignName
            Next fld
            Debug.Print "=========================="
        Next rl
        
        db.Close
        
        Set db = Nothing

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jan 2000
    Location
    Leeds
    Posts
    30
    Thanks a lot this is exactly what i was looking for..



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width