Reading field names from dao.recordset

  • Thread starter Thread starter janiotjoeawie via AccessMonster.com
  • Start date Start date
J

janiotjoeawie via AccessMonster.com

In order to make an output script I need to read the field names from my
recordset. The field names are known but I need it to write a flexible script.

I've wrote the following:
Dim rs As dao.Recordset

Set rs = CurrentDb.OpenRecordset("Update_relations")

Open "C:\Documents and Settings\Desktop\TEXTFILE.TXT" For Output As #1

What I'm now lookig for is something like rs.field(0).name (but this is not
working)
Anybody any ideas.

Regards
 
What is it that your are trying to do with the name? If you are trying to
apply it to a variable, this should work.

strVariable = rs.Fields(0).Name

or, if you want to do something with the recordset itself:

With rs
.Edit
.Fields(0).Name = strVariable
.Update
..End With

Two other things I noticed... your example has .field(0) rather than
..fields(0)
You might not have explicitly moved to the record you want (I belive it
moves to the fisrt record be default, though I make it a habit to leave
nothing up to defaults). Maybe you already have this but didn't put it in
your example.
 
Thankx,

Al lot this was exactly what I'm looking for .

Many regards
What is it that your are trying to do with the name? If you are trying to
apply it to a variable, this should work.

strVariable = rs.Fields(0).Name

or, if you want to do something with the recordset itself:

With rs
.Edit
.Fields(0).Name = strVariable
.Update
.End With

Two other things I noticed... your example has .field(0) rather than
.fields(0)
You might not have explicitly moved to the record you want (I belive it
moves to the fisrt record be default, though I make it a habit to leave
nothing up to defaults). Maybe you already have this but didn't put it in
your example.
In order to make an output script I need to read the field names from my
recordset. The field names are known but I need it to write a flexible script.
[quoted text clipped - 11 lines]
 
Back
Top