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

Phantom record when form regains focus

Status
Not open for further replies.

mthompso

Programmer
Apr 9, 2002
22
CA
After closing a modal form, the calling form ends up on a record that doesn't exist. Here's what happens.

I have two forms, projects and photos, which operate on separate tables in the same database. A toolbar button on Projects is used to open the photos form, and it is always opened modally.

Every time, after closing Photos, a "phantom" record seems to be created at the end of projects. Like so:

Here are the project numbers before calling photos, square brackets indicate the one displayed:

293, [294], 295, 297

Here's what it looks like after closing photos and returning to projects:

293, 294, 295, 297, [294]

EXCEPT that the last "294" isn't real. If one tries to save it, a "No current record error" is returned.

I have tried setting a bookmark, opening the photos form, and when returning from it, moving last then moving to the bookmark, but the same thing happens. Using debug.print shows that the bookmark has successfully re-positioned the record pointer on the correct record, yet the form is sitting on a phantom.

Help would be appreciated - Miles Thompson
Code is:
bkPosition = rsProjects.Bookmark
Debug.Print "Projects", rsProjects.AbsolutePosition
frmImages.Show vbModal
rsProjects.MoveLast
Debug.Print "Projects", rsProjects.AbsolutePosition
rsProjects.Bookmark = bkPosition
Debug.Print "Projects-Set to Bookmark", rsProjects.AbsolutePosition
frmProjects.Refresh

Output from the 3 debug.print's is:
Projects 22
Projects 24
Projects-Set to Bookmark 22
/mt

 
o.k in what event do u load the datas? (form_activate?)

Known is handfull, Unknown is worldfull
 

Do both tables have identically the same recordcount?
 

And are the cursor locations, types, etc, identical?
 
vbkris ...

Thank you for jogging me about the form activate event.

That's where the problem was, had nothing to do with the shift of focus.

The record pointer was on the correct record; code the original programmer had written moved the record pointer, then tested for project id - a loop which continued until EOF. Hence the phantom record.

Moved the "movenext" to the end of the loop, and all was well - and it fixed up the return from other associated forms as well.

Regards - Miles Thompson
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top