Easy question, need help on how to find the position of a record

  • Thread starter Thread starter Michael Rodriguez
  • Start date Start date
M

Michael Rodriguez

I have a basic customer data entry screen where the sort order is customer
name. Given a customer's ID#, I need to find the position of that record in
the list that is sorted by name, i.e. in the form's currency manager. In
order to move the record on the screen to the record I want, I would need to
something like myCurrencyManager.Position = 3.

As an example, suppose I want to find customer #1 (Amy) in the following
customer records:

ID# Name
3 Bill
4 Bob
1 Amy
2 Susy

I know how to find a record based on the id#. Just create a dataview, sort
it by id#, and find the given value. The problem is, when the dataview is
sorted by id#, finding id=1 will return the position in the dataview, which
when sorted by id# will be position #1. When the list is sorted by name,
the record I want is really in position #3.

Given the above data, what code can I use to tell me that the record with id
#1 is in position #3 when the list is sorted by name? Am I missing
something really obvious here?

TIA,

Mike Rodriguez
 
You can access the data, and make any necessary changes through the
dataview.

To answer your question though, no way to figure out the number of the row
in the initial collection. It is annoying that datarow does not have this
property. It might be related to that the row can exist outside of a
collection, but in that case it could be -1 or something. For whatever
reasons though, there is no way to get this.
 
Back
Top