Reading field names from dao.recordset

  • Thread starter janiotjoeawie via AccessMonster.com
  • 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
 
D

Dymondjack

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.
 
J

janiotjoeawie via AccessMonster.com

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]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top