> I'm putting together an application for a local non-profit that takes a
> csv
[quoted text clipped - 10 lines]
> Of course, if a more straightforward method exists, I would be a happy
> camper.
I think you're going to have to give an example: that's still too abstract
for me.

Signature
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
PMFJI,
If you just want to get the names of the fields in the new table, you
can open a recordset and look through its Fields collection:
Sub ListFieldsInTable(TableName As String)
Dim rsR As dao.Recordset
Dim fldF As dao.Field
Dim j As Long
'Open a recordset with no actual records
Set rsR = CurrentDb.OpenRecordset("SELECT * FROM " & TableName _
& " WHERE FALSE;", dbOpenSnapshot)
With rsR.Fields
For j = 0 To .Count - 1
Debug.Print .Item(j).Name
Next
End With
rsR.Close
End Sub
If I understand the situation right you're thinking in terms of a
translation table that maps the field names you expect to find in the
incoming csv files onto the names you have used in your "permanent"
table, e.g.
CSVField, PermanentField, TableName
FirstName, FirstName, Contacts
FName, FirstName, Contacts
First Name, FirstName, Contacts
...
If so, you can call DLookup() in the For..Next loop, and use the values
it returns to build the SQL statement for an append query that maps the
field names for you, along these lines:
INSERT INTO Contacts (FirstName, MiddleName, LastName ...)
SELECT FName, MI, LName ... FROM CSVTable;
>> What's the exact problem you're trying to solve?
>
[quoted text clipped - 14 lines]
>
>George
--
John Nurick [Microsoft Access MVP]
Please respond in the newgroup and not by email.
GeoBrooks - 15 Dec 2005 01:22 GMT
> If so, you can call DLookup() in the For..Next loop, and use the values
> it returns to build the SQL statement for an append query that maps the
> field names for you, along these lines:
>
> INSERT INTO Contacts (FirstName, MiddleName, LastName ...)
> SELECT FName, MI, LName ... FROM CSVTable;
Doug & John,
Thanks for all your replies.
Doug, here's an example from a translation table:
fformfield ftblname ffldname
DayReqd topp fdayreqd
email tnpo fEmail
(hope formatting is not lost)
where fformfield is the field name as it appears in the csv file; ftblname
is the destination table; ffldname is the field in the destination table.
John,
Thanks for the insight on using dlookup() in the loop.
I was hoping for some elegant way to build field names, maybe using ordinals.
George