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

Quick search or pop up with an array

Status
Not open for further replies.

Steve-vfp9user

Programmer
Feb 5, 2013
337
GB
Hello

I have been looking for a way to use a text field on a form where the user can start entering a four digit code and reference to it either appears to confirm the correct code or a look up can be used if not sure.

These are two examples I found:


The codes are stored in a table called NOMCODES with fields:
NOMURN N(10)
NOMINAL C(4)
NOMDESC C(70)

The codes are stored in an array using:

Code:
DIMENSION mynoms(1)
IF file("nomcodes.dbf")
  SELECT NOMINAL FROM nomcodes ORDER BY NOMINAL INTO ARRAY mynoms
ELSE
* Show error message etc
  RETURN
ENDIF

I have tried several ways of doing this by putting a list box on the form which shows the codes and using the builder option where you select from the list box which populates the required field and the examples I have shown above use fields from a table.

I'm a little lost on this one (as you can probably see) but all I'm trying to achieve is:

The user starts typing the code, ideally it would be shown as a label next to the text box or alternatively if the code is not known, I can use a look up table/grid with some sort of incremental search, the information from table NOMCODES field NOMINAL is subsequently stored in table MYTABLE field NOMINAL etc.

I am aware of the incremental search as a seperate entity (
Your suggestions would be appreciated.

Thank you

Steve
 
You can the autocomplete feature of the textbox in VFP9. The autocomplete table must have a precis structure (very well documented in help)

Code:
PUBLIC oFrm as MyForm
oFrm=CREATEOBJECT("MyForm")
oFrm.Show()

DEFINE CLASS MyForm as Form
	ADD OBJECT txt as Textbox WITH top=100,autocomplete=1,AutoCompTable="MySource",AutoCompSource="TXT"
	PROCEDURE load
		LOCAL lni
		RAND(-1)
		* Simulate your table
		CREATE CURSOR NOMCODES (NOMURN N(10),NOMINAL C(4),NOMDESC C(70))
		FOR lni=1 TO 100
			INSERT INTO NOMCODES (NOMINAL) VALUES (TRANSFORM(FLOOR(9999*RAND())))
		NEXT
		
		* Create the AutoCompTable 
		CREATE TABLE MySource (Source C(20),Data C(254),Count I,Weight I,Created T,updated T,user M)
		INSERT INTO MySource (Source,Data,count,created,updated) ;
			SELECT "TXT",; && usually the name of the textbox, the value of AutoCompSource
				NOMINAL,; && values from your table
				1,DATETIME(),DATETIME() from NOMCODES 
		USE IN MySource
	ENDPROC
ENDDEFINE

Respectfully,
Vilhelm-Ion Praisach
Resita, Romania
 
Why not use the code of alvechurchdata. All you need to replace is postcode with your table nomcodes. Just open the table, set order to the field you want to seek in and that would be it. Autocomplete would be an advance to that in that it'll complete the code, if the starting letters/digits match.

Even simpler you could use a combobox in dropdownlist mode and set incrementalsearch=.t.

Bye, Olaf.
 
I appreciate the posts. Will have a look and come back with result.

Thank you

Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top