Link to home
Start Free TrialLog in
Avatar of Dan Flood
Dan Flood

asked on

a FOR EACH ... NEXT loop problem with each field in a selected record

I can't seem to figure out to select each item in a selected record.  The Record (Formula) has about 200 fields in it.  I would like to so a:

FOR EACH  field in the selected database record

    console.writeline( that fields value )

NEXT

Formula is  dim'ed as DataSet.tblFormulas.FindByCODE("2331")

Maybe it's late and I'm foggy, but I can't figure out how to do this....

Thanks
ASKER CERTIFIED SOLUTION
Avatar of Wayne Taylor (webtubbs)
Wayne Taylor (webtubbs)
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Dan Flood
Dan Flood

ASKER

Thank you both very much - this was extremely helpfull
Hi,

 yes the .FindByCODE("xxxxxx") is an automatically generated routine that returns a datarow.   VB creates the    .FindBy<that_tables_key(something)

This was exactly the guidance I was looking for.  Thanks!
argh

It is telling me that my row isn't a collection type  (formula is a datarow of table  tblFormulas

 For Each item As DataColumn In Formula  ' (formula is underlined with this error:  Expression is of type 'dtfDataSet.tblFormulasRow', which is not a collection type.      )

            Console.WriteLine(item.ColumnName & " = " & item.ToString)

        Next
That's because your code, unlike either Wayne's or mine, is treating Formula _itself_ as the collection.  If you look at Wayne's code it used For Each on Formula.Table.Columns, and Columns is a Collection.  If you look at mine it used For Each on dr.ItemArray, and ItemArray is a Collection.

Roger