I have a code to read the PK from tables, and write them to a table where I save the full structure
For some weird reason I get an error that Access can't locate a table (A connected table) I already removed from my db :banghead:
I get an error
Run Time errro 3078
Access can't find the table or query XXXX, make sure it exist and properly spelled
It shouldn't be exist as I alredy removed it from my db
here is the code I use (I marked where error appear)
For some weird reason I get an error that Access can't locate a table (A connected table) I already removed from my db :banghead:
I get an error
Run Time errro 3078
Access can't find the table or query XXXX, make sure it exist and properly spelled
It shouldn't be exist as I alredy removed it from my db
here is the code I use (I marked where error appear)
Code:
' --- Find PrimaryKey
For Each tdf In CurrDB.TableDefs
' If the table has a connect string, it's a linked table.
If Len(tdf.Connect) > 0 Then
[COLOR="DarkOrange"]For Each idxLoop In tdf.Indexes[/COLOR]
With idxLoop
For Each prpLoop In idxLoop.Properties
Select Case prpLoop.Name
Case "Primary" ' --- PrimaryKey
If prpLoop.Value = True Then
hldPrimary = True
Else
hldPrimary = False
End If
Case "Unique" ' --- Unique
If prpLoop.Value = True Then
hldUnique = True
Else
hldUnique = False
End If
Case "IgnoreNulls" ' --- IgnoreNulls
If prpLoop.Value = True Then
hldIgnoreNulls = True
Else
hldIgnoreNulls = False
End If
Case "Foreign" ' --- Foreign Key
If prpLoop.Value = True Then
hldForeign = True
Else
hldForeign = False
End If
Case Else
End Select
Next prpLoop
' --- Now catch up the Fields that making up this Index
For Each fldLoop In idxLoop.Fields
strSQL = "SELECT * FROM [TablesStructure_Table] " & _
"WHERE [TableName] = '" & tdf.Name & "' AND [ColumnName] = '" & fldLoop.Name & "' "
Set rs = CurrDB.OpenRecordset(strSQL)
With rs
rs.MoveFirst
rs.Edit
If idxLoop.Name = "PrimaryKey" And hldPrimary = True Then
rs.Fields("ColumnPrimaryKey") = True
End If
rs.Update
End With
rs.Close
Next fldLoop
End With
Next idxLoop
End If
Next tdf