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!

How to continously run a Form (loop the Form) 3

Status
Not open for further replies.

cgc22

Programmer
Jan 17, 2007
10
US
Hi
I'm using Visual Foxpro 8.0. FORM NAME "UpDateInv"
I have a FORM that has labels & textboxes with one COMMAND
button & one CANCEL button. This is for updating a .dbf
file, so each time the USER is finished updating one record they can search for a NEW RECORD(USING THE COMMAND BUTTON) and edit the textboxes. This is a form and not a formset. I wrote the following code in COMMAND button:

In the COMMAND button "click event" CODE:
DO FORM UpdateInv ??opens up the SAME FORM again!

In the COMMAND button "lost focus event" CODE:
Thisform.Release ?? closes out previous, but SAME FORM

If I cancel out the "Lost Focus" code then Foxpro keeps the
form and just creats another of the same form again & again. So if the USER updates 50 records I have 50 forms
to cancel out !!!

If I keep the "Lost Focus" code "thisform.release", I
get a message, "FILE IS IN USE" from FOXPRO the first time
only. Then I can continously use this same FORM over and
over again. I know this is not the correct way to go.
Any suggestions? Can I just REFRESH all Textboxes and
Labels? I want the USER to just click the COMMAND button
to refresh all textboxes & labels and search for a new
stock number or should I create a formset for this form?

Regards
Greg
 
If I understand what you're trying to do, there's no reason to keep closing and re-opening the form. You just need to clear or update the ControlSources of the controls on the form.

For example, if you're adding new records, you would follow the code that saves a record with:

APPEND BLANK
ThisForm.Refresh()

to start a new record.

However, it sounds like you're looking at existing data. It also sounds like you already have code to search for the right record. Once you find it, you just need:

ThisForm.Refresh()

to update the controls.

Tamar
 
Hi Greg,

I can't help thinking that your approach is not ideal from the user interface viewpoint. At the very least, the user will see your form flash off and then flash on again, each time they click the command button.

Also, if the user has moved the form, the next time it opens it will be back in its original position (unless you have saved the position when closing and restored it when opening), so the user will also see the form jumping around the screen.

I would suggest you take a different approach, perhaps along the lines that Tamar suggested.

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Hello Greg:


Mike's suggestion is the way to go. but if you are new as I am, may be you can use the following idea

1. in the init of the main (calling) form
public cx_SecondForm
cx_SecondForm = null


2. in the Command1.Click event,
if vartype(cx_SecondForm) = 'O' && Object
cx_SecondForm.release
endif
DO FORM UpdateInv


3. And in the init of UpdateInv
cx_SecondForm = thisform


this is a quick fix, not a quick program.

try it

Nasib Kalsi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top