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

Trouble closing a form programatically

Status
Not open for further replies.

opticalman

Programmer
Nov 6, 2006
103
US
I am using FVP8

My top level form PT_INFO calls form LIST _SERVICES
LIST_SERVICES calls SERVICE_INFO.

If while the SERVICE_INFO form is active, I call MySCHEDULE, I get an error when MySCHEDULE tries to close PT_INFO. Let me add that closing PT_INFO causes LIST_SERVICES and SERVICE_INFO to close also, since they are linked.

The error is "rv_Services not found". Somehow it is trying to close the remote view rv_Service after it is already closed.

If I step through the program, there are no errors. If I release the variable frmSERVICE_INFO from the command prompt the SERVICE_INFO form closes, but if MySCHEDULE programatically releases the variable frmSERVICE_INFO, the form does not close until PT_INFO is released.

I'm stumped. Any suggestions are appreciated.

Jim Rumbaugh
 
Is rv_services used in a combo or list by any chance? Usually this sort of error occurs when list is trying to access a source that is not available...

----
Andy Kramek
Visual FoxPro MVP
 
Also, since PT_INFO creates the instance of LIST _SERVICES, LIST _SERVICES still has an open reference to PT_INFO. PT_INFO can't be released until that reference goes away.
Have you thought about just hiding the forms instead of releasing them?

Also, are you using NAME or LINKED in your code to run the forms?


-Dave Summers-
[cheers]
Even more Fox stuff at:
 
AndyKr

REMOTE VIEW rv_Services supplies data for the forms:

LIST_SERVICES and
SERVICE_INFO

form LIST_SERVICES is a grid describing the service
form SERVICE_INFO has standard field boxes with service details

form PT_INFO calls
form LIST_SERVICE which calls
form SERVICE_INFO

when the program breaks, the trace widow is pointing to
PT_INFO.RELEASE && this is the line where error occurs

If I look at the screen, I can see that the LIST_SERVICE form is gone from the PT_INFO form, but the SERVICE_INFO form is still on the screen.

Because stepping through the processes via DEBUG results in no error, I am wondering if this is some type of problem from Multi-threads trying to do something at the same time. I do have multiple RELEASE SomeVariable statements in the DESTROY events of these forms. I admit, I have limited knowledge about how these could interact.

Jim Rumbaugh
 
Dave

I may reconsider just hiding the forms or letting them stay. My original problem was that MySchedule will call PT_INFO to make the patient appointment. The second call to PT_INFO was my concern. If I was in the middle of entering service information when I scheduled an apointment for another patient, the service information may not be properly saved. I have not tried private data sessions yet. And perhaps, re-examing how I save the data may slove my previous problems. But as it stands now, if a PT_INFO form is open when MySCHEDULE is called, the original PT_INFO idnumber is saved. When MySCHEDULE exits, it calls PT_INFO again with the saved ID. My current problem is trying to get PT_INFO to shut down if it has called LIST_ SERVICES and SERVICE_INFO. Odd, the problem does not occur if only LIST_SERVICES is open.

Thanks for you input

Jim Rumbaugh
 
To All

Maybe my questions should be:
Under what conditions could you NOT close a form from another active form?

OR what is wrong with only calling

RELEASE SomeForm && or SomeForm.RELEASE

Jim Rumbaugh
 
Dave

I just re-read your question. You asked how LIST_SERVICE calls SERVICE_INFO:

DO FORM SERVICE_INFO WITH THISFORM.LEFT , THISFORM.TOP NAME frmServices LINKED

Jim Rumbaugh
 
Thank you both for your input.

I have narrowed down my problem to a fault on the SERVICE_INFO form of unknown nature. After backing up the original form, I stripped out most on the form's content and saved it. The program then works the way it is suppose to work. I will need to dig through the form piece by piece to isolate the problem...... and it's a big form. Oh well....

I consider this thread closed

Jim Rumbaugh
 
Postscript

As for now, here is my fix.

I had to make sure the FOCUS of the form was on a CONTROL not a FIELD.
If the FOCUS was on a FIELD, VFP was trying to read the data for the field before closing the form, but the REMOTE VIEW was already gone, thus an error. For some reason, unknown to me, by setting the FOCUS on the COMMAND BUTTON, I am now able to close the form with no problems. I have been able to repeat the error in other forms in my application, by interrupting an editing session with a call to MySchedule. I get a similar error when the scheduling module tries to close other forms while the focus is on a field.

I hope this may help some other poor soul that runs into a problem like mine.

Jim Rumbaugh

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top