Thanks for taking the time to read my question.
I have code that I am using to tell me info about fields in a table. It
is in a loop so I can move through all the fields in the table.
db.TableDefs(x).Fields(i)
Is it possible to tell which field is the primary key? If yes, then
how? I can't find anything to add to db.TableDefs(x).Fields(i).???? to
get Primary Key info.
I'd like to be able to have the code in this loop.
Here is my loop right now:
---------------------------------------------------
Dim x As Integer, db As Database, rst As Recordset
Dim NumOfRecs As Integer
Set db = CurrentDb
Set rst = db.OpenRecordset("tblTableDetails")
On Error GoTo ViewProperties_Err
x = 0
Do Until x = DLookup("CountOfName", "qryNumberOfTables") + 7
If db.TableDefs(x).Name = Me.lst_TableNames Then
For i = 0 To db.TableDefs(x).Fields.Count - 1
With rst
.AddNew
!FieldName = db.TableDefs(x).Fields(i).Name
If db.TableDefs(x).Fields(i).Type = 10 Then
!FieldType = "Text"
!FieldSize = db.TableDefs(x).Fields(i).Size
Else
If db.TableDefs(x).Fields(i).Type = 4 Then
!FieldType = "Integer"
ElseIf db.TableDefs(x).Fields(i).Type = 7 Then
!FieldType = "Double"
ElseIf db.TableDefs(x).Fields(i).Type = 8 Then
!FieldType = "Date"
End If
End If
.Update
End With
Next
NumberOfRecs = db.TableDefs(x).RecordCount
Exit Do
End If
x = x + 1
Loop
---------------------------------------------------
Thanks so very much for your help.
Brad
*** Sent via Developersdex
http://www.developersdex.com ***