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

Running the same form over and over till done

Status
Not open for further replies.

FoxEgg

Programmer
Mar 24, 2002
749
AU
I am putting in data to a patient file... (finally)


I am using a form with text box with a search for an Item Number to populate a grid.
Then selecting from the grid ...
Selecting the particular Item Number then using an Array.. appending from the Array and using INSERT INTO for certain other pieces of data.
and I get another line in the required dbf() (actually a table.. whoops sorry Olaf.. I myself am heritage)
So I get a complete new entry (I'm Happy)

ALL GOOD..

Is there some way that I can do this recursively (ie over and over) ie same form, search for yet another Item Number and add yet another line (with same INSERT INTO etc) over and over

I might have 5 additions to make

AND maybe, one time... I select an Item that don't like ... and I don't want to add THAT entry but I want to keep going select another Item Number....

etc etc


Until I click a button and it releases the form....

I gave it a shot ... but couldn't get recurrent action.

Appreciate a little guidance


Foxy

(now 12MN, bed)

Sydney, Australia
 
Sure. Just don't release the form after the first insert. Only do the insert when you specifically want that one insert, and then clear out the search textbox so it's ready for more.

What you'll often find, particularly when you're new to VFP coming from previous FP versions, is you're trying to do too much and getting in the way of what VFP will actually do for you if you'll just let it. :)
 
> in the required dbf() (actually a table.. whoops sorry Olaf...
You can say table or dbf, that's ok, just don't say database. I know dbf stands for data base file, but dbc (actually database container) was introduced long time ago, and the term database in generally describes a database with all its tables, view, constraints, rules, stored procs, etc. and should be avoided for talking about a table.

Anyway, Dan is giving the right advice. I don't know why you can't repeat your code. You'd put it in a click and then each click repeats that. You will know that and have already used that many times.

Bye, Olaf.
 
Hi Dan

Cant sleep... SO lets solve this...

That is what I think I did... but the code still only did one pass.. and dropped out the bottom and went back to another place

Code:
INSERT STUFF IS UP HERE


RELEASE Temp                   Just releases the temp array that I used for the adding info bit
MESSAGEBOX(Add_More)           Just a test
*!*	SET STEP ON            And I watched it...

IF Add_More = "T"
thisform.pageframe1.page7.text1.value = " "      reset the item number select box or clear it out as                                               you said
thisform.pageframe1.page7.text2.value = " "      reset another box wich shows the service that goes                                             with the item number  
thisform.pageframe1.page7.text1.SetFocus         set focus back to item number selector   
thisform.Refresh()

ELSE

SELECT patient_accounts
SET ORDER TO 
GO bott
RELEASE patient_data_entry4                      here is where I released the form if Add_More was "F"

ENDIF


... But i watched the set step go to then end and back to the evil and much dreaded form one

{{Longing for old MS BASIC where I could just GO TO LINE 34}}

J


Sydney, Australia
 
Just to nit-pick for a moment, you asked if you can do it "recursively". Recursively is what happens when a function calls another instance of itself to operate on a sub-set of the original data. Drilling down through a tree is an example of a recursive operation. The function starts by operating on the tree as a whole, then it calls itself to operate on a sub-tree, than it calls itself to operate on a sub-sub-tree, and so on.

The word you want is "iteratively". Of course, everyone here will know what you mean. But one of the hallmarks of good computer programming is choosing the right tools (in this case, the right words) for the job. And other people you meet in your work might not be as forgiving.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
>back to the evil and much dreaded form one

This is Init code, or what? Code doesn't help us without knowing context.

Is this code in a non modal form? If - as you say - form one gets back control, then this form isn't modal. That shouldn't matter at all, if you've got a READ EVENTs, but if you do this form linked to a variable, eg by NAME clause or via oForm = CreateObject(), its lifetime of course depends on the scope of that variable.

Eg to think of a simple example you call form two in click of a button of form one and form two vanishes after the click method ends, then the culprit is not starting form two in a way it stays open. Modal is not the only solution. A simple DO FORM formtwo WITH parameters will also establish a stable and staying form two, once you have a READ EVENTS.

What is your design? If you use formtwo to execute code, then close right away, simply stop doing so, if your choice of item is in form one, then also put the code adding record in form one, why seperate this at all into a form that does end right away?

Overall, your whole contexts are unknown and this is making it wild guessing, I don't thnik I can help you with more than a wake up call to rethink your overall design, you got stuck in something that needs a refactoring.

And you won't solve that sleepy. Good night.

Bye, Olaf.

 
Couldn't sleep.. 2:30am

Apologies for the incorrect wording and phrases... I KNEW I should have put that 'recursive' in quotes...

Mike, correct

The word you (I) want(ed) is (was) "iteratively"

Slayed again... like fodder to the cannons, I am...

Apologies Olaf.. I have had a very long day fighting with misbehaving Forms and Filters and self incompetence...

Explanation

First...

To make it hopefully more clear....

I have a form where I add data to a TABLE (<-- Olaf, give me a tick box for using the correct non legacy word)
When data added it currently returns elsewhere (doesn't mater where that is).. release form etc etc
BUT I would love to cycle thru that same form 'over and over' and not leave until I have added several more entries
Indeed until I have had elegant sufficiency...
THEN and ONLY THEN... return elsewhere.

My somewhat dodgy code is located in a Command Box Click event.. entitled 'Append'...
But it doesn't seem to return control to that form.. instead.. it goes back to that elsewhere form

But I still want to iteratively add more items

Does that explanation of what I am trying to do get me out of VFP jail ?

I hope so////

JF

Legacy.Legend.value = "FOX"

Actually it is a bit like a DO WHILE X in FPD2.6
etc etc
etc etc
IE Doing something until some condition is met

.... Legacy rears its head again

FPD2.6 Legacy Human
Sydney, Australia
 
BUT I would love to cycle thru that same form 'over and over' and not leave until I have added several more entries

Since this is the default behavior of a form (unless you interfere) it should be pretty easy to do. Unless you interfered. :)

Forms are different than the old FPD "screen programs" which were run-once programs from top to bottom. Try this in the command window:

Code:
foo = Createobject("form")
foo.Show()

The form is going to hang around until you close it.

If any form you run has a command button on it with with, for example, Cancel=.t. then the form will close when that button is clicked. You can also release the form by calling its release method of course. The point is that YOU MUST DO something to release the form.

The only way the form will go away on its own is if its object variable goes out of scope, and variable scoping bites MANY people moving to VFP from earlier versions, even though it works exactly the same way. It's packaged differently so it throws people.
 
What Dan says.

>RELEASE patient_data_entry4
As far as I see, this is the only thing releasing something.
In MSDN forms I lately saw someone even do RELEASE THISFORM, which indeed also works, but as dan says you
a) don't do anything for a form to stay
b) call Thisform.Release() or let the variable referencing the form go out of scope.

Without context = calling code, there is nothing there to help you.

Bye, Olaf.
 
From reading the replies, you have all you need to complete the task.

Then I went to read your post again. What do you do after you fill Item Number in the Textbox ? (hit enter or press a command button, etc.)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top