Hi,
This is giving me a headache! I guess there's something I don't
understand about BEGIN TRANSACTION/END TRANSACTION.
Changes I make to two tables revert back.
Below is some code executed when the user wants to change the key field
in the Symbols table (the field name is Symbol). Referential integrity
requires that I also change any occurrence of the changed Symbol in the
Securities table.
When I step through the code I can see the changes are being made. The
comments in the code below indicate that. But when I exit the
application, they revert back to the old values.
Here are a few possibly significant factors.
1. Even though the field temporarily changes in the Symbols table, the
modified record appears at the bottom of the table even though the index
order is on that same field (Symbol). I expected the changed record to
take its normal place in the index order. It doesn't.
2. I'm using the buttonbar that is automatically placed on the form when
I use the Form Wizard. There is a lot of code in there (much of which I
don't understand) that may be screwing things up.
3. This is VFP9
4. I've tried using "automatic" referential integrity in the database but
when I omit the operations on the Securities table (in the code below);
the rows in that table don't change.
Any thoughts would be greatly appreciated.
Thanks, Frank
Code snipped begins here:
BEGIN TRANSACTION
SELECT Symbols
REPLACE Symbol WITH m.NewName
* The record does change
SEEK(m.NewName)
SELECT Securities
m.recno = RECNO()
m.OldFilt = FILTER()
SET FILTER TO Symbol = m.OldName
LOCATE
REPLACE ALL Symbol WITH m.NewName
* All records that match Oldname change to Newname.
SET FILTER TO &OldFilt
TRY
GO RECNO
CATCH
GO TOP
ENDTRY
END TRANSACTION
SELECT Symbols
SEEK(m.NewName)
ThisForm.pgefrmSYMBOLS.PgeSymbols.cmboSymbol.Requery
=ThisForm.PgeFrmSymbols.pgeSymbols.REFRESH()
end of code.