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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Recordset field reference with variable 2

Status
Not open for further replies.

alr0

Programmer
May 9, 2001
211
US
Hi All,

I'm sure I did this somewhere in the past but the syntax escapes me.

rst!arFields(intFlds)

where:

rst = recordset
arFields = array with field names
intFlds = looping integer

I tried [] "" & etc. and cannot seem to get the field name recognized. This must be possible right!

Any insights much appreciated.

Thanks,

alr

_____________________________________
If a large part of intelligence is the ability to generalize, it is ironic that a large part of what we call wisdom is the ability not to generalize.
 
Hi!

Like this:

rst.Fields("arFields(intFlds)")

hth


Jeff Bridgham
Purdue University
Graduate School
Data Analyst
 
How are ya alr0 . . .
Code:
[blue]   rst!(arFields(intFlds))[/blue]

Calvin.gif
See Ya! . . . . . .
 
Hey!

I made a mistake, it should be:

rst.Fields(arFields(intFlds))

hth


Jeff Bridgham
Purdue University
Graduate School
Data Analyst
 
jebry . . .

SynTax for a field in a recordset for what you've shown is:
Code:
[blue]   rst("FieldName")[/blue]

[blue]The quotations are required if you type in a literal in code[/blue]. Since your using an literal array, quotes are not required! . . . For example:
Code:
[blue] Dim Name as string

   FieldName = "AccountNumber"
   rst(FieldName) = 12345[/blue]
Here the field name is AccountNumber! . . . [purple]can you see it?[/purple]

Calvin.gif
See Ya! . . . . . .
 
Hey AceMan!

Yes, that is why I reposted with the correction. I know that the .Fields isn't required since it is the default, but I prefer to use it for the better readability or in case MS ever changes the default.

Thanks for your post.


Jeff Bridgham
Purdue University
Graduate School
Data Analyst
 
Don't know, I guess he got what he needed and ran!

Jeff Bridgham
Purdue University
Graduate School
Data Analyst
 
PERISH THE THOUGHT

"...got what he needed and ran!" INDEED.

I did get busy because even arbitrary deadlines are important to someone but no point in going on with paragraphs about my pet peeves.

I too was surprised the fields designator was needed in this case but I used it, it worked, and I ran with it. (so to speak)

Thank you both for your input

alr

_____________________________________
If a large part of intelligence is the ability to generalize, it is ironic that a large part of what we call wisdom is the ability not to generalize.
 
Hi arl!

Sorry, I didn't stop to consider how that sounded. I didn't mean to call your integrety into question! As you said, perish the thought!

I'm glad it worked for you!


Jeff Bridgham
Purdue University
Graduate School
Data Analyst
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top