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!

Forms in FoxPro 6.0 3

Status
Not open for further replies.

Phil Thoms

Programmer
Oct 31, 2005
245
GB
I have used the old foxpro for many years and I am trying to build a simple form in version 6.0 which I have just started using. I require the user to type a character field into a text box and search a large database. The fields displayed will be restricted to only a few and then I need to run a report against the selected records. I need to know where to put the code for these actions. Thanks.
 
Hi

You put the code in the button's 'click' method.

You can access this via the properties page for the object an use the methods tab to find the click - or you could just double click on the button and the editor will open in the click method.

Good luck

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.
 
"I require the user to type a character field into a text box and search a large database"

The Click method that Griff suggests would be applicable if you have a Button which the user clicks on to initiate the Search.

If you want the search to be initiated after the user has entered the value into the text box, you would most likely put the code into the textbox's Valid method.

One thing I often do is to create a new Form property WhenValue. Then in each textbox's When method I store the original value. Then in the Valid method I retrieve the WhenValue and compare it to the current value so that I can determine if something has actually changed.

If nothing was changed, just leave the method (RETURN). There isn't much point in running the same code over and over on the same un-changed value.

If something was changed, then I run the desired code within the Valid method.

Good Luck,
JRB-Bldr
 
KRB-Bldr,

that's fine, but you should also add, that the valid method only runs, when the user tabs away from the textbox.

If you want such a thing to run interactively while the user types there is the .IncrementalSearch property of eg the listbox or combobox. You bind a list of data to it and while the user types the list will scroll to the match. An incremental search ends, when the user needs more than the time interval defined in _dblclick. In later versions this has a seperate system variable called _incseek.

Consider changing this to 1 or 2 seconds, or only fast typers will be able to make use of the incremental search.

That said it does not apply to the textbox, as that is not reasonly but rather allows editing of values or entering new ones, but there is the InteractiveChange event you can use to react to any letter typed. You can combine that with JRB-Bldrs idea of a Value storing the previous value, but InteractiveChange really just is run, if there is a change, eg not if you simply move around with left or right arrow.

There are also ready to use incremental search textbox classes at Universal Threads Download section, if you don't want to switch to list- or combobox and the native .IncrementalSearch property and mechanism. For example Download-ID: 32394 (
Another note: There is also a similar feature called Autocomplete you can use with a textbox, but that needs data in the format of an autocomplete table to be usable for this way of autocompletion of partly entered values. It may not be applicable here.

Bye, Olaf.
 
In regar to the last mentioned autocomplete: It's not available in VFP6, so yes, it's not applicable anyway. I think it was added in VFP9, may also have been VFP8, but it surely wasn't available in VFP7 or earlier.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top