Click to See Complete Forum and Search --> : few questions
pies
Mar 15th, 2000, 05:15 PM
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
Clunietp
Mar 15th, 2000, 10:58 PM
#1 Field data types
'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
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
pies
Mar 16th, 2000, 03:28 AM
Thanks a lot this is exactly what i was looking for..
:D
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.