hi Steve,
I am creating a table on the fly which can contain from 1 to 20 columns. I
am then using a macro to sent the table to a file (or whatever). The problem
is it always sends the first column which is the autonumber column which I do
not want.
Hence my desire to do it via VB code.
Okay. You also need to create a query on the fly to export instead of
your table. I assume you know the fieldname of your ID field (untested):
Dim Count As Long
Dim dbc As DAO.Database
Dim Statement As String
Dim tdf As DAO.TableDef
Set dbc = CurrentDb
Set tdf = dbc.TableDefs.Item("YourTable")
Statement = ""
For Count = 0 To tdf.Fields.Count - 1
If tdf.Fields.Item(Count).Name <> "IDFIELDNAME" Then
Statement = Statement & ", " & tdf.Fields.Item(Count)
End If
Next Count
Statement = "SELECT " & Right(Statement, Len(Statement) - 2) & _
"FROM yourTable"
dbc.CreateQueryDef AName, Statement
mfG
--> stefan <--