Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VFP9 strange behavior with current working area and cursors (forms,grids and reports) 1

Status
Not open for further replies.

DanyAlbai

Programmer
Aug 27, 2012
2
RO
Sometimes, vfp9 selects different working area, without any "select" command; I tried to find some answers on the internet, but I didn't found anything, so I'll try to explain here and maybe someone can help ...

So:
Case 1:
I have a form (form1) with a grid (grid1) and a command button (command1) in it; inside the "Init" method of the form I do this: "create cursor c1(... fields ...)" and thisform.grid1.recordSource="c1".
Then, on the "click" event of command1 I create another cursor (c2) and then run another form (form2) with another grid in it, with the record source set to c2.
The problem is that, even if i issue a "select c2" before "do form form2", when form2 shows up, the selected working area is c1, and I would really want to know why (the workaround for this problem was to put "select c2" on the form2's "Activate" method). What is interesting is that this not occurs all the time; in some cases works normally.

Case 2:
Something similar with the first case (form grid, command button) but this time, on click event, after I create the cursor (and fill it with data) I want run a report; what is very strange here is that the report shows up ok (preview), but when I try to zoom in, the selected area changes from c2 to c1, and I got an error, and then the report closes.
If the first case was (kind of) easy to fix, the second one left me without any solution, so if anyone have an ideea, I'm all ears (I mean .. eyes :) )
 
The reason for both behaviors is the grid selects it's own recordsource. In many events and at random times. There even is a know workaround for the report problem to set focus to a non bound textbox to stop the grid from selecting it's workarea while the report runs.

It's not only me thinking so. For example it's also described here:
Even if you have no other control on the form you can set focus to, add a textbox off screen and use that to set focus away from the grid via thisform.offtextbox.setfocus() and both problems vanish.

Bye, Olaf.
 
Thank you very much for your reply! You really saved me. It works perfectly. Thanks again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top