Quote:
I am planning to tackle a larger csv file and was wondering if it is possible to have the table columns entered programmatically.
...
I'm wondering if I'd need to read first line first then set as table column or maybe something like that but I'm not really sure on how to go about doing it.
It depends on csv content and
HasFieldNames
parameter for
DoCmd.TransferText Method (Access)[
^].
As official documentation states:
Quote:
Use True (1)
to use the first row of the text file as field names when importing, exporting, or linking. Use False (0)
to treat the first row of the text file as normal data. If you leave this argument blank, the default ( False
) is assumed. This argument is ignored for Microsoft Word mail merge data files, which must always contain the field names in the first row.
As per my experience, if you set
HasFieldNames
parameter to
False
, the names of columns are added automatically and they start with:
F1
,
F2
,
F3
,..., etc.
Conclusion: you have to check (and optionally ask a user) if first row is a header row, then depending on it to pass
True/False
to
HasFieldNames
argument.