Verifying a table fields in a loop
Author Message
Verifying a table fields in a loop

HELLO;
I have a table that have 20 fields named D1,D2,D3...........D20 .Can i  read
this fields value in a loop using DAO,and save them in an array for current
record?(e.g writing something like this inside loop: myArray(i)=rs!D & i )
for now,no matter on which record curser is.
Thank you for ur feedback.THX.

Sat, 05 Mar 2005 00:35:47 GMT
Verifying a table fields in a loop
Funny field names. Makes me wonder what they're for. What is it?

This having said: you don't have to make any assumptions on the field names,
using DAO

dim fd as field
dim i as integer
i=1
for each fd in yourRecordset.fields
yourArray(i)=fd.value
i=i+1
next

Please note that you may know the number of fields, now - but I don't. Hence
the counter i.

--
Regards,
Bas Cost Budde, Nieuwegein, Holland
website at http://www.heuveltop.nl/BasCB/msac_index.html
Please post replies to the newsgroup so everyone can benefit

Quote:

>HELLO;
>I have a table that have 20 fields named D1,D2,D3...........D20 .Can i
>this fields value in a loop using DAO,and save them in an array for current
>record?(e.g writing something like this inside loop: myArray(i)=rs!D & i )
>for now,no matter on which record curser is.

Fri, 04 Mar 2005 01:17:19 GMT
Verifying a table fields in a loop

Quote:

>I have a table that have 20 fields named D1,D2,D3...........D20 .Can i  read
>this fields value in a loop using DAO,and save them in an array for current
>record?(e.g writing something like this inside loop: myArray(i)=rs!D & i )
>for now,no matter on which record curser is.

myArray(i)=rs.Fields("D" & i )

--
Marsh
MVP [MS Access]

Fri, 04 Mar 2005 01:46:38 GMT
Verifying a table fields in a loop
Thank you Mr.Barton
Reading ur suggestion,I remembered this method of calling fields of a
recordset.I think it can be easier.Is this true:
MyArray(i)=rs("D" & i)   ?
Thanx again.

Sat, 05 Mar 2005 06:09:46 GMT
Verifying a table fields in a loop
While that will work, it's only because Field is the default property of a
recordset, and it's possible (although very unlikely) that that could change
in the future.

Marsh's myArray(i)=rs.Fields("D" & i ) is safer (and possibly marginally
faster, although I doubt you'd notice a difference)

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele

Quote:
> Thank you Mr.Barton
> Reading ur suggestion,I remembered this method of calling fields of a
> recordset.I think it can be easier.Is this true:
> MyArray(i)=rs("D" & i)   ?
> Thanx again.

Fri, 04 Mar 2005 06:37:48 GMT
Verifying a table fields in a loop
Thank you so much for ur help.
This fields are mostly prescribed {*filter*} on a registered prescription(in a
table),and rest are some details like Date of prescription,its ID,Insurance
type of presc. and so on.I have to register all of a presc. in a record of
this table,and my question was to recall them to view or edit.
very very appreciated,THX.

Sat, 05 Mar 2005 06:22:01 GMT
Verifying a table fields in a loop
Thank you so much for ur help.

Quote:
> While that will work, it's only because Field is the default property of a
> recordset, and it's possible (although very unlikely) that that could
change
> in the future.

> Marsh's myArray(i)=rs.Fields("D" & i ) is safer (and possibly marginally
> faster, although I doubt you'd notice a difference)

> --
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele

> > Thank you Mr.Barton
> > Reading ur suggestion,I remembered this method of calling fields of a
> > recordset.I think it can be easier.Is this true:
> > MyArray(i)=rs("D" & i)   ?
> > Thanx again.

Mon, 07 Mar 2005 07:29:42 GMT

 Page 1 of 1 [ 7 post ]

Relevant Pages