New records not in order

scotttt

Member
Joined
Sep 8, 2005
Messages
8
Programming Experience
Beginner
I have a form written in vb.net that updates an access db This works fine and I check the table and the record is sitting atthe bottom with the primary key (bookingid) 1 number more that the last record.

The problem i have is when I fill a datagrid with the data in the table the last record I added shows in the middel of the data so the primary key field will be as follows 34,35,36,248,37,28,29.
When I look at the table in access it looks fine.

I can't sort the datagrid as I use a double click to fill another form using the row position and if I sort the data to get it in order the row position is wrong.

I deleted the primary key(bookingid) and re-input 1-248 and the datagrid picked them up in the correct order but as i added a new record the same problem.

Can anyone explain?

Regards

Scott
 
Well i could not fix it so changed the form to include a search box rather than choosing from the datagrid. (looks better)
I would be interested in knowing why this happens. It seems that the primary key groups next to a foreign key in the next collumn.
For example
PK 6,7,8,56,9,10
FK 2,3,7, 7 ,3, 2
So rather than showing the PK in numerical order it is grouping against the FK.
I have no relationship links in access and the Form is only updating from 1 table.
Cheers
Scott
 
You can sort the data in your query from the database or configure a sort system within the datagrid, but sorting is up to you to handle.
 
Thanks for the reply, Sorting through the SQL is not a problem as is sorting the data grid but because I used the double click in the data grid to obtain the row number and then updated a new form by using the row number as a reference source. I had trouble as double clicking could give me row 12 but when the new form updates, row 12(13) in access was different to what i clicked on.

In theory it should work and was the 1st thing I tried.
I was wondering if there was some indexing access has that you dont see as I would assume that what i see in access I should see in the same order in the datagrid. It was only new records and they seemed to get grouped by like fields in the next collumn, but only when the datagrid shows them, as the access table shows it how it should be.

Weird!

Thanks for the reply

Scott
 
Back
Top