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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unable to write to underlying form 3

Status
Not open for further replies.

coldan

Programmer
Oct 19, 2008
98
AU
I am puzzled because I am sure I have been able to write to a visible ( during app run) form whilst I am running a routine in a prg file started by clicking a [Next] button on the form.

I want to update a total records processed as I scan through a table and select records with the desired content in a particular field - appended to another table.

The form filename is frmglobaltl
The name value for the form is GlobalsTL

This name also appears in the Call Stack in the debugger.

whereas I can find a thisform object when I am on the main form I cannot find

frmglobaltl or GlobalTL as objects in the debugger as I come to these code lines in the prg file.

Trying everything here...

frmglobaltl.EXHNumPot.DisplayValue = Str(mynumber,5,0)
frmglobaltl.EXHNumPot.DisplayValue = Str(mynewrecords,5,0)

GlobalTL.EXHNumPot.DisplayValue = Str(mynumber,5,0)
GlobalTL.EXHNumPot.DisplayValue = Str(mynewrecords,5,0)

Can anyone suggest things I can try to accomplish this?

Thanks

Coldan
 
What happens when you try?

If you don't get an error, perhaps VFP is just too busy to update the unerdeying form.

You could try either a DOEVENTS() or simply giving the controls in question a little bit of focus:

GlobalTL.EXHNumPot.Setfocus()

That usually does it for me.

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.
 
Coldan,

Griff is right. If you're trying to update the form while you're in a loop, VFP won't have an opportunity to process the update. This is a common problem when displaying progress counters the like.

One solution is to introduce a very small delay within the loop. For example, like this:

Code:
* At start of program:
DECLARE INTEGER Sleep INTEGER
......
* In your loop code:
DO WHILE <something>
  Sleep(50)
  frmglobaltl.EXHNumPot.DisplayValue = Str(mynumber,5,0)
  
  * more processing
ENDDO

Of course, this will slow down your code a bit. You have to decide if it's better for the code to run fast but without any feedback to the user, or for it to run almost as fast, and with the user seeing a progress report.

Or, you could try the other things that Griff suggested. I don't know which is better from the performance point of view.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
Did you call the form with the "NAME" paramater
Code:
DO FORM myForm [b]NAME[/b] myFormName

If you did not their is no external reference to that form.

If you did, did you declare the variable for your form name as PUBLIC?

Code:
PUBLIC myFormName
DO FORM myForm NAME myFormName
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top