Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select Ordinal position

Status
Not open for further replies.

FederalProgrammer

Programmer
Jul 2, 2003
318
CA
I am trying to write a SQL-Query that Selects a column based on its position on the table... ie, I want the 4th column of my table, but I don't know its name...
Is there a way to do this?

thanx in advance!
 
You can pick off the 4th column from the Fields Collection on the table, then build a dynamic sql statement with the column name.

 
I'm not sure I follow?
The table is in the database... what collection are you exactly referring?
do you mind elaborating a bit further please?
thanx!
 
I assume an Access database or whatever database is on the CurrentProject.Connection.

'-- set reference to ADOX library
'- Microsoft ADO Ext. 2.6 for DDL and Security
'-- Microsoft ActiveX data objects 2.6 library also needed for ADO

Dim cg As New ADOX.Catalog
Dim tb As New ADOX.Table
Dim cn As ADODB.Connection
Dim cl As Column
Dim pp As Property

Set cg.ActiveConnection = CurrentProject.Connection

Set tb = cg.tables("yourtable")
Set cl = tb.Columns(3)
Debug.Print "property name = "; cl.Name
 
Anyway, strange question, as in a relational database the order of the columns in a row is irrelevant...
 
Well, PHV
I need to access the 4th column of my table not knowing what the name of the column is going to be. How would you do it?!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top