Hi Cor,
Thanks for the tip. I got it to work (finally!), but let me give you the
full story of what I had to do...
1. had to make all references to the databinding equal to the
ds.tables("myfilename").defaultview (previously I just used
ds.tables("myfilename") )
2. using the defaultview.sort put my added record in order, BUT it affected
the positioning of my databinding the next time I added a record. That is,
the first time I added a record (when the sort was not in effect) I added
the new row and positioned to the last record (ie: count-1). During the
processing of the added record I did the defaultview.sort so the added
record was in it's proper order, HOWEVER the next time I added a record
(the key field is blank when adding a new record) the position of the record
was 0 and NOT count-1 (because of the sort). So, I simply moved the
defaultview.sort statement to the form.load sub and now I always position to
row 0 when entering the data for a newly added record, and everything works
fine.
Thanks again for the help.
John
"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
news:Oa****************@tk2msftngp13.phx.gbl...
John,
I have a table in a dataset whose fields are bound to various controls on
my form. The records are sorted by primary key so when I use the
currencymanager to navigate the data, it all appears sorted. When I add
a new row to this table and save it (using dataadapter.update) it appears
at the end of the list no matter where it should fall in the sorted list.
Gladly enough otherwise I would never be able to do this
ds.tables(x).rows(count-1) = the last added record
When I exit and re-enter the form the newly added record is then
presented in the proper sorted order. Clearly when re-entering the form
I reload the dataset, create all the data bindings, etc all from scratch.
My question is that, short of reloading the entire dataset and recreating
the bindings, what do I need to do to "reorder" the data once I add the
new row so that the new row will appear in the proper place in the list.
I've tried a CurrencyManager.Refresh and sorting the dataset.table by the
proper column, but in each case the Currencymanager seems to get confused
and all types of weirdness happens.
Any suggestions? Thanks...
Use the dataview or better just the defaultview which is the same inbuild
in every datatable
ds.tables(0).defaultview.sort = "Mycolumn" is enough
whatever.datasource = ds.tables(0).defaultview
I hope this helps,
Cor