Connecting Tech Pros Worldwide Forums | Help | Site Map

Selecting a column without knowing its name

Rob Tiemens
Guest
 
Posts: n/a
#1: Nov 13 '05
hello,

I need to select the first and the second column of a table. But I
don't know the names of the columns.

Is there any way I can select only the first column from a table
without knowing the columnname ?

Regards

Rob Tiemens

Tom van Stiphout
Guest
 
Posts: n/a
#2: Nov 13 '05

re: Selecting a column without knowing its name


On 15 Apr 2005 01:04:15 -0700, robtiemens@gmail.com (Rob Tiemens)
wrote:

You could create a dynamic SQL statement. Something like:
dim sql as string
dim db as dao.database
dim td as dao.tabledef
set db=currentdb
set ts=db.tabledefs("MyTable")
sql="select " & td.fields(0).name & "," & td.fields(1).name & " from
MyTable"

Now you can use this sql as your form's recordsource or as the basis
for opening a recordset, etc.

-Tom.

[color=blue]
>hello,
>
>I need to select the first and the second column of a table. But I
>don't know the names of the columns.
>
>Is there any way I can select only the first column from a table
>without knowing the columnname ?
>
>Regards
>
>Rob Tiemens[/color]

Closed Thread


Similar Microsoft Access / VBA bytes