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

How to exit a form after executing a query from within the form

Status
Not open for further replies.

mfrag44

Programmer
Jun 14, 2016
5
US
I have written a small application that loads a form, reads & displays information from a customer file then runs a report. A problem occurs when the query finishes and control returns to the form. When I click my exit command button on the form, it does not release the form, instead it displays the last record I read from the customer file. I have to click the exit button a second time for it to release the form. Any help will be greatly appreciated.
 
When you say "the exit button", is this a command button you have placed on the form? Or are you referring to the standard Windows Close button (the big X) in the top right corner?

If the former, what code do you have in the command button's Click event.

You would normally have [tt]THISFORM.Release[/tt]. If this is the "main" form in the application (that is, you launched it from your main program, immediately before calling [tt]READ EVENTS[/tt]), then you also need [tt]CLEAR EVENTS[/tt] in the Click event.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
instead it displays the last record I read from the customer file

What kind of display? There's nothing native about a command button that will display *anything* so there's code in its click medtho. Open 'er up and have a look.

As Mike says, you'd need at minimum Thisform.release or set the button's Cancel property to .t., and make sure there's a CLEAR EVENTS if you're in a READ EVENTS (which you may not be in if the form is modal).
 
Thank you for your reply. Let me clarify my problem.
1. The form is launched from a simple form menu I created.
2. The form with the problem has a command button I placed on the form.
3. That command button has one command in the click event, 'Thisform.release"
4. As long as I don't execute the query which is called by a command button within theform, the form releases without a problem when I click the exit command button I placed on the form.
5. The problem shows up after I execute the query from a command button I placed on the form.
6. After the query runs and control returns to the form, clicking the exit button I placed on the form does not release the form. When I click the button the first time, the last record I displayed before executing the query appears. I must click my exit button one or two times to exit the form.

thanks again for any suggestion.
mfrag44
 
I completely redid the form. The new form works perfectly. Thanks for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top