This is the most bizarre behaviour I've seen yet in VFP7.

I have a form that allows add/edit of 2 related files, a
header with detail records. When I click the Add button,
it adds a record to the header( recno -1) and the detail
(recno -1) automatically. If I click revert, I issue
TABLEREVERT on both tables and everything is fine.

When I click Add again, it again adds a record to the
header( recno -1) and the detail but this time recno is -2
even though there is no recno -1 on the file (I checked
this at the command box with GO -1).

This I don't understand but what's more, if during this
add I go off to a totally unrelated form and do and Add on
it and then Save which does a TABLEUPDATE on a completely
different table, when I hit the END TRANSACTION of this
table's Save code, the record number on the totally
unrelated file changes from -2 to -1, so my code that
tries to position on the correct record number on the
details file when returning to the screen crashes with EOF
encountered.

Help!!! I can't see any way of fixing this behaviour.

Bernie

Re: VFP7 weird problem with buffered added records by Rick

Rick
Fri Sep 12 08:22:20 CDT 2003

Bernie,
As you have discovered, the record number of a buffered record is =
"dynamic" and is only reliable internally to VFP. If you are linking to =
another table, you should use a true unique (primary/candidate) key and =
NEVER depend on the record number. When you do a table update, then VFP =
will assign the "true" record number based on what's next available at =
that time. I believe this behavior is documented in the help file.

Rick

"Bernie Beattie" <bernie@landmaster.co.uk> wrote in message =
news:0afa01c37928$ef30c770$a401280a@phx.gbl...
> This is the most bizarre behaviour I've seen yet in VFP7.
>=20
> I have a form that allows add/edit of 2 related files, a=20
> header with detail records. When I click the Add button,=20
> it adds a record to the header( recno -1) and the detail
> (recno -1) automatically. If I click revert, I issue=20
> TABLEREVERT on both tables and everything is fine.=20
>=20
> When I click Add again, it again adds a record to the=20
> header( recno -1) and the detail but this time recno is -2=20
> even though there is no recno -1 on the file (I checked=20
> this at the command box with GO -1).=20
>=20
> This I don't understand but what's more, if during this=20
> add I go off to a totally unrelated form and do and Add on=20
> it and then Save which does a TABLEUPDATE on a completely=20
> different table, when I hit the END TRANSACTION of this=20
> table's Save code, the record number on the totally=20
> unrelated file changes from -2 to -1, so my code that=20
> tries to position on the correct record number on the=20
> details file when returning to the screen crashes with EOF=20
> encountered.
>=20
> Help!!! I can't see any way of fixing this behaviour.
>=20
> Bernie