>Define Class form1 As Form > > > Top = 3 > Left = 48 > Height = 100 > Width = 375 > DoCreate = .T. > ShowTips = .T. > Caption = "Auto Complete" > Name = "Form1" > > > Add Object command1 As CommandButton With ; > Top = 67, ; > Left = 278, ; > Height = 27, ; > Width = 84, ; > Caption = "Close", ; > TabIndex = 2, ; > Name = "Command1" > > > Add Object label1 As Label With ; > AutoSize = .T., ; > Caption = "Name", ; > Height = 17, ; > Left = 60, ; > Top = 25, ; > Width = 55, ; > TabIndex = 3, ; > Name = "Label1" > > > Add Object text1 As TextBox With ; > Format = "K", ; > Height = 23, ; > Left = 120, ; > SelectOnEntry = .T., ; > TabIndex = 1, ; > Top = 20, ; > Width = 207, ; > Name = "Text1" > > > Procedure Load > If Used("customer") > Use In customer > Endif > **** Do not need to do this if there is an Index > Set Exclusive On > ************************************************ > Select 0 > Use Home()+"samples\data\customer.dbf" > ************************************************ > Index On company Tag company > Set Order To Tag company > ************************************************ > Endproc > > > Procedure command1.Click > Thisform.Release > Endproc > > > Procedure text1.InteractiveChange > With This > If (Lastkey() >= 32 And Lastkey() <= 127) > .nIDSelStart = Icase(.nIDSelStart >= 0 And Lastkey() = 127,.nIDSelStart - 1,; > .nIDSelStart < 0,0,; > .nIDSelStart + 1) > Select customer > coldtag = Tag() > Set Order To Tag company > Locate For Substr(Alltrim(Upper(customer.company)),1,.nIDSelStart) = ; > Upper(Substr(This.Value,1,.nIDSelStart)) > ***** Could use a SEEK() as well > If Found() > This.Value = customer.company > Else > If !Empty(This.Value) > .nIDSelStart = This.SelStart > Else > .nIDSelStart = 0 > Endif > Endif > This.SelStart = .nIDSelStart > Set Order To Tag (coldtag) > Endif > Endwith > This.SelLength = Iif(!Empty(This.Value),(Len(Alltrim(This.Value))-(This.nIDSelStart)),1) > Endproc > > > Procedure text1.Init > If !Pemstatus(This,"nIDSelStart",5) > This.AddProperty("nIDSelStart",0) > Endif > Endproc > > >Enddefine >