I was programming a little today and I stumbled upon an unexpected problem:
I have a form with a grid. In the grid there is a click event. Doesn't matter if its grid.click or grid1.column1.text1.click.
The table of the grid is in workarea 1, but the currently selected workarea = 2 (with select 2 selected)
Then I click in the grid and the click event is executed:
This behaviour does not occur if this code is placed in a cmdButton.click event on the form. If area 2 has no table open it also does not occur.
It only occurs in a grid when doing an other form and both areas have tables open.
Any replace command following the do form will be performed in the wrong and unexpeced workarea/table.
Why is that? Is there any logic behind this? The code above is simplified to isolate and demonstrate the problem.
I have a form with a grid. In the grid there is a click event. Doesn't matter if its grid.click or grid1.column1.text1.click.
The table of the grid is in workarea 1, but the currently selected workarea = 2 (with select 2 selected)
Then I click in the grid and the click event is executed:
Code:
* to be sure I select the workarea of the grid table
select 1
do form dummyfrm && this is a dummy form, does nothing, is modal and desktop=.t. and it can confirm that workarea = 1 !!!
* but for some mysterious reason it changes the workarea back to 2 after releasing dummyfrm
messagebox(str(select())) && 2, why 2?
select 1
messagebox('hello') && no change in workarea
messagebox(str(select())) && still 1
This behaviour does not occur if this code is placed in a cmdButton.click event on the form. If area 2 has no table open it also does not occur.
It only occurs in a grid when doing an other form and both areas have tables open.
Any replace command following the do form will be performed in the wrong and unexpeced workarea/table.
Why is that? Is there any logic behind this? The code above is simplified to isolate and demonstrate the problem.