Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
NOUPDATE Autocomplete property?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9
Database:
Visual FoxPro
Divers
Thread ID:
01040758
Message ID:
01040849
Vues:
17
This message has been marked as a message which has helped to the initial question of the thread.
>Hi All
>I'd like to implement a mechanism similar to Autocomplete , but i do not want new values to be entered into the Autocomp table, nor modified, nor deleted. The Autocomp table is, thus, just a lookup table. Can i tweak Autocomplete to do that, or should i mimic it's behaviour and create the whole stuff from scratch??
>
>Jaime

Hi Jaime,
I can perhaps do something for you.

This is a way for implement a lookup with autocomplete.
With Source Field you can grouping multiple lookup tables
into a single lookupTable.
PUBLIC oform1

oform1=NEWOBJECT("form1")
oform1.Show
RETURN

DEFINE CLASS form1 AS form

	DoCreate = .T.
	Caption = "Autocomplete Lookup"
	Name = "Form1"


	ADD OBJECT text1 AS textbox WITH ;
		Height = 23, ;
		Left = 46, ;
		Top = 46, ;
		Width = 278, ;
		Format = 'F',;
		AutoCompSource = PADR("GROUP1",20), ;
		AutoCompTable = "LookupTable", ;
		Name = "Text1"


	ADD OBJECT command1 AS commandbutton WITH ;
		Top = 8, ;
		Left = 50, ;
		Height = 27, ;
		Width = 84, ;
		Caption = "Command1", ;
		Name = "Command1"


	PROCEDURE Load
		CREATE TABLE LookupTable FREE;	&& you cannot to use a Cursor
		(	Source	C(20)	NOT NULL	;	&& Lookup Group
		,	Data	V(50)	NOT NULL	;	&& Data item to display.
		,	PK		I					;
		)
		INSERT INTO LookupTable VALUES ('GROUP1','First'	,1)
		INSERT INTO LookupTable VALUES ('GROUP1','Second'	,2)

		INDEX ON UPPER(Source+Data) FOR NOT DELETED() TAG DATA	&& non funziona senza l'indice

		USE	&& share
	ENDPROC


	PROCEDURE text1.GotFocus
		this.AutoComplete = 1	&& Enable Lookup
	ENDPROC


	PROCEDURE text1.Valid
		SELECT 0
		USE (M.THIS.AutoCompTable) AGAIN
		* ANOTHER
		* SELECT PK FROM ALIAS() WHERE UPPER(Source+Data) LIKE UPPER(PADR(M.THIS.AutoCompSource,20)+m.this.Value)+'%' INTO ARRAY aPK
		* IF EMPTY(_TALLY)
		IF NOT SEEK(UPPER(M.THIS.AutoCompSource+m.this.Value),SELECT(0),'DATA')
			USE
			MESSAGEBOX("INVALID ITEM")
			RETURN .F.
		ENDIF
		* OK
		this.AutoComplete = 0	&& DISABLE
		MESSAGEBOX("SELECTED A VALID ITEM. PRIMARY KEY IS"+STR(pk))
		USE
	ENDPROC

ENDDEFINE
Don't hesitate, and ask me explanations in the case this is you useful.

Fabio
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform