Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Updating and Reading Records in Access via ADODC controls.

Status
Not open for further replies.

logo

Programmer
Aug 22, 2001
56
0
0
US
I am a bit perplexed! Perhaps a seasoned VB/ACCESS programmer can shed some light on my problem.

I created a program which reads and writes records to ACCESS 2000 via Visual Basic's ADODC control. Currently my table contains aprox. 120 records. When I add a new record it appended to the "END" (last record) of the table. However, as I navigate through the recordset using my VB application--the record actually appears somewhere in the middle (ie. as record 83--or so).

I expect that when I "movelast", "addnew" , "update" the recordset, then "moveprevious" . . . that I should be staring at the record which I just added. For some reason this is not the case. (my record, which is appended to the end of the table, comes up somewhere in the middle of the record set when I navigate via my VB app.)

To my knowledge I have added no sort features to my application.

Any Ideas?? Has anyone else experienced this problem?
 
It looks like your table has and index and/or key on some column. I would take a look at the indexes and keys for that table.
One way to make sure the record you just added will be at the end without doing a movelast before you save is to make an autonumber field as a primary key for the table. You can then save the record then do a movelast to get to the record you just saved.

Hope this helps

Adam
 
Yes, I do have it indexed by a date and time field. But my application is not displaying the records from the earliest date to the latest.

Hmmm????

I am in the process of double-checking all of my fields to see if there are any other indexes.
 
I'm not 100% sure why new records are appended to the end, but don't stay there when you hit the database again. I do know from my experience that after you've added a record and it's at the end of the recordset, adding child records to this can cause an error unless you refresh the recordset (using a VB program to add records, not Access). If you're just curious why the new record doesn't stay at the end (and don't have a particular reason to want it to stay there), I recommend you run a Adodc1.Recordset.Refresh immediately after adding any parent record. That will avoid the error I mentioned above when adding children. Problem with that is after refreshing, your AbsolutePosition will be at the first record, not the one that was just added. In that case, just do a Adodc1.Recordset.Find and search for the PK that was just added. It probably won't be at the end like before, but now it's safe to add children.

Just FYI, that small detail took me 2 days to figure out :(

-Mike Difference between a madman and a genius:
A madman uses his genius destructively,
A genius uses his madness constructively.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top