When linking to an external data source via ODBC (especially an AS/400), I often run into cryptic field names on the other side, where a data dictionary is not available. In the rare event that I'm able to get the field descriptions from the other db, I would like to be able to import them all at once, rather than copy/paste each description into the table design form one at a time.
I wasn't able to find this in the system tables, so I don't know where this metadata is stored. Any ideas on where it is, and whether it can be updated in batch?
Update: I managed to read the schema using the OpenSchema method (see code below), but this returns a read-only dataset, making it impossible for me to update the descriptions.
Function UpdateFieldDescriptions()
Dim cn As New ADODB.Connection
Dim rs As ADODB.Recordset
Dim rs2 As Recordset
Dim strSQL As String
Dim strDesc As String
Set cn = CurrentProject.Connection
Set rs = cn.OpenSchema(adSchemaColumns)
While Not rs.EOF
If Left(rs!table_name, 4) <> "MSys" Then
Debug.Print rs!table_name, rs!column_name, rs!Description
strSQL = "SELECT Description " & _
"FROM tblColumnDescriptions a " & _
"WHERE a.Name = """ & rs!table_name & """ AND " & _
"a.Column = """ & rs!column_name & """;"
Set rs2 = CurrentDb.OpenRecordset(strSQL)
While Not rs2.EOF
strDesc = rs2.Fields(0)
rs!Description = strDesc ' <---This generates an error
Wend
End If
rs.MoveNext
Wend
rs.Update
rs.Close
Set rs = Nothing
Set rs2 = Nothing
Set cn = Nothing
End Function