Import Field Description

G

Guest

Hi,
I need to import data from spread sheet. On the spread sheet, the first row
is the names of the fields, the 2nd row has the description for each field.
Is there any way I can import the 2nd row as the field description for the
table, in addition to the names of each field from the 1st row. We usually
can see the field decription for each field when we open the table design
view. Thanks.
 
D

Douglas J. Steele

Not as part of the data import.

You'd have to import to a temporary table (or link to the spreadsheet), then
use VBA to open a recordset against that table and add the property to each
field.
 
D

Douglas J. Steele

Sorry, not kicking around, because I've never needed to do it.

Note that the field's Description property does not exist by default. You
need to use the CreateProperty method to make it work. A function like the
following might help:

Sub AddDescription( _
TableName As String, _
FieldName As String, _
Description As String _
)
On Error GoTo Err_AddDescription

Dim fldCurr As DAO.Field
Dim prpDescription As DAO.Property

Set fldCurr = CurrentDb.TableDefs(TableName).Fields(FieldName)
fldCurr.Properties("Description") = Description

End_AddDescription:
Exit Sub

Err_AddDescription:
Select Case Err.Number
Case 3265 ' Item not found in collection
MsgBox "Either " & TableName & " isn't a valid table, " & _
"or " & FieldName & " isn't a valid field in that table."
Case 3270 ' Property not found
Set prpDescription = fldCurr.CreateProperty( _
"Description", dbText, Description)
fldCurr.Properties.Append prpDescription
Case Else
MsgBox "ERROR & Err.Number & ": " & _
Err.Description
End Select
Resume End_AddDescription

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top