Moving to a specific record on a bound form

  • Thread starter Thread starter Gerry Schatte
  • Start date Start date
G

Gerry Schatte

If I know the primary key value of a record and want to move my form
to that specific record, what is the best way?

I know how to "move next", "move previous" or use the position to move
to a specific record with BindingContext, but the position is based on
datarow position, not primary key id.

I was hoping there'd be something like:
Me.BindingContext(dsPeople, "People").Position.Move = [pk value], but
can't find it.

I suppose I could iterate through the datatable to find a pk match and
then move to the position, but that seems archaic to me. I can use
the find method to locate the datarow of choice in code, but I'd like
to be able to move my form to that record.

TIA,
Gerry
 
Gerry -

If you are working with a typed dataset you should have access to a special
method "FindBy" with the primary key column in the name, here's an example
of the method name "dataset.FindByAuthorID" where "AuthorID" is the name of
your column.

Here is a link from MSDN that may clarify it a little better for you:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/
vbwlkwalkthroughusingdatagridwebcontroltoreadwritedata.asp

It is a long article so you can probably just search the article for
"FindBy" and that will give the info you are looking for.

Hope this helps.

Bart A. Robinson, MCP
 
Thanks for the reply. I should have been more clear that I have NO
prolems finding the record I'm looking for in a dataset (even though I
wasn't using that method), but once I FIND that record, how do I
SYNCHRONIZE my form?

I find the record I'm looking for in code, but all the bound controls
on the form still display the original record.

Thanks,
Gerry
 
Back
Top