>Hello all
>
>VFP8, 2 Forms
>
>
>Here's the idea:
>Form 1 gets initial data (batch number, remit number range) and then calls Form 2.
>
>Form 2 uses a grid to allow data entry of money amounts. I've got a keypress event at the cell level. This event checks to see if the 'Enter' key was pressed, and if so - does a Down Arrow and then a Left Arrow. Basically I need the 'Enter' key to march down the grid, staying in the same column. When user is finished, they hit the 'Save' button which closes Form 2 and returns to Form one for the next batch.
>
>Here's the problem:
>
>First time through, Form 1 works fine, Form 2 works fine, returns to Form 1, Form 1 works fine, goes to Form 2 and now the Keypress event is being completely ignored - like it doesn't exist
>
>
>Here's the plea:
>
>Does this sound familiar to anyone? Does anyone have any ideas of how to fix this?
>
>Help me, please?
Seems like you're re-creating the underlying cursor for that grid, or switching record source on it. When a grid gets a new recordsource, it deletes all columns and builds them from scratch, using default columns with default textboxes, which (surprised?) don't have your KeyPress code.
There should be at least three ways out of this:
- instead of re-creating the cursor, zap it, create another one and then append from it into the first one. The grid keeps its recordsource and won't autorebuild.
- kill form2 when it exits, create afresh each time. May work a little slower, but this requires just a couple of lines of code
- keep the records you want form2 to use in a table, and have the grid in form2 use a parametrized local view on that table. Then each time you revisit form2, you only have to requery the view. A bit more coding, but feasible as well - specially if you accidentally already have such a view.