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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

datacontrol won't move next

Status
Not open for further replies.

goldi

Programmer
Mar 21, 2001
31
US
I use an Access '97 database and a datacontrol (dao 3.6). I can browse through the file using the datacontrols arrows to move next. I reach a certain record and the datacontrol will not move to the next record. There is no error. What could be wrong and how do I fix it?
 
Are you sure that's not the LAST record? If it is, and the Data1.EOFAction = 0 - MoveLast, that would explain your symptom.

Hope that helps!

-Mike Any man willing to sacrifice liberty for security deserves neither liberty nor security.

-Ben Franklin
 
No, I am positive it is not the last record. It's in the middle of the table. The only thing that is different about this record, it is the only one I added using my VB program and not imported directly into the database from another table. I can seek for the record after it and I can use the data control to move previous to it and beyond it. If I am moving next through the table and I reach this record I can go no further moving next.
 
The only event that is triggered when the 'move next' arrow is clicked is the MOUSEDOWN event. It doesn't trigger the VALIDATE or the REPOSITION event.
 
Ok, if you restart the application after adding the new record, does it work then? If so, calling a Data1.Refresh after AddNew/Update may fix it. When you add a new record to a recordset, it gets appended to the end. When you Update, it's written to the database, but your Recordset (in memory) still has it at the end. Calling Refresh will repopulate your Recordset with the new info from the DB, with the new record in the right place (not necessarily at the end). It sounds like the Data1 thinks the new record is still at the end of the Recordset. In reality it IS still at the end until you Refresh, at least as far as the Data control is concerned.

Also, Validate and Reposition don't fire if EOF = True, so that's another reason I think this is the problem.

Let me know if this doesn't do it...

-Mike

Any man willing to sacrifice liberty for security deserves neither liberty nor security.

-Ben Franklin
 
No, if I restart the application the problem is still there. Issuing a Refresh did nothing. I deleted the record and I could move Next through the entire file. I added that record back and I can move Next until I hit that record then nothing....

I added another record through the program and now I can browse past the original 'bad' record but now I am stuck on the new one. So, it has to have something to do with the new record being at the end of the file and the data control seeing it there, but how do I fix it? Refresh does nothing and restarting the program does nothing. I have an index set, why does it not see that? (The records are in the correct order, even the 'bad' one).

I have other programs that I have written in VB using an Access database and the DAO datacontrol and I have never run into this before.
 
I can't seem to duplicate your problem on my machine, but I have noticed where the Data1 will add the new record to the end of the list, and it seems to stay there after a Refresh or recycling the app. I guess only ADO repositions the new record like I was saying...

The only thing I can think is to add this code to make SURE you're not at EOF when you hit the newly added record:

Private Sub Data1_Reposition()
Data1.Caption = "Record " & Data1.Recordset.AbsolutePosition + 1 & " of " & Data1.Recordset.RecordCount

End Sub

Also, try MoveFirst, then MoveLast on the Data1. If you're on the problem record after MoveLast, then there is no problem, it's just still the last record.

If nothing else, depending on the size of your project, you may be able to switch to the Adodc1 in mid stream, maybe the .ocx that contains your Data1 got corrupt?

-Mike
Any man willing to sacrifice liberty for security deserves neither liberty nor security.

-Ben Franklin
 
It's fixed!! I did have EOFAction set to Move Last. I kept thinking about what you said about the new record being at the end of the file. If I had actually listened to what you said in the first place I would have had it fixed after your first reply. I changed the EOFAction on the datacontrol to EOF and it worked. I was able to browse past the new record. I had to add a couple of lines elsewhere to deal with hitting EOF, but not a problem!

Doesn't really make sense to me since the record wasn't at the end of the file as far as the sorted order goes, but it was at the end since it was the newest record. What is really confusing is the fact the EOF is not triggered until I hit the end of the sort order not the physical end of file (which of course is the newly added record).

Thank you so much for your help!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top