Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Addnew event in grid?
Message
 
To
05/12/2000 11:23:56
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00449399
Message ID:
00449451
Views:
8
>Hello,
> when the grid allowaddnew set to .t., we can append a new record by pressing the down arrow at the last row.
> Can my program run some codes when a new record is append? except the 'insert trigger' method.
>
>Thanks
>-Jasper

Hi Jasper,

Just an idea, just invented. :)
One way to do is to store the RECCOUNT() to, say, the form or grid property .nRecs in BeforeRowColChange() event:

thisform.nRecs = reccount(this.recordsource) && or, reccount(alias())
and check it again in .AfterRowColChange() event:

IF RECCOUNT(this.recordsource) > thisform.nRecs
WAIT WINDOW "A new record is added"
* more code here.
ENDIF

You may also add to grid.Init() :

thisform.nRecs = reccount(this.recordsource)

so the code is not executed on the grid initialization. If you use the table buffering you can use the fact that the records are getting negative RECNO when added and issue

* AfterRowColChange() event
IF RECNO() < 0 AND RECCOUNT(this.recordsource) > thisform.nRecs
WAIT WINDOW "A new record is added"
* more code here.
ENDIF

All this assumes that the grid.recordsource is a table. You might need to do some modifications if you are using view or SQL statement as a recordsource. etc.
Nick Neklioudov
Universal Thread Consultant
3 times Microsoft MVP - Visual FoxPro

"I have not failed. I've just found 10,000 ways that don't work." - Thomas Edison
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform