Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Activating A List From Within A Valid Event
Message
From
14/10/2002 13:13:27
Carmen Gassi
Perseus Software Systems
Oakville, Ontario, Canada
 
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00710933
Message ID:
00711000
Views:
10
>>>Hi Carmen,
>>>
>>>I have the same situation in DataEntry application. The valid of textbox calls form's method, which it turn invokes a new form with the listbox.
>>>
>>>
>>>>Hello
>>>> I'm not sure how you get around this one, I've managed to work around it in other parts of applications, but I would like to find out how a lot of you get at the solution. In the valid event of a text box, I would like to activate a list of correct choices if the user has entered an incorrect name or employee number. I am able to make the list visible, but am not allowed to setfocus to the list. If the list has to be scrolled up or down or simply to choose a correct name from the list I am unable to do that because not allowed to call setfocus from within a valid event. I could default focus to the list and take the name from the list before the user keys any data in, but the users like to use the keyboard in this particular form and having to move the mouse when not necessary wouuld slow them down. So how can you get around the setfocus issue from within a valid event?
>>>>
>>>>Thanks as always,
>>>>Carmen
>>Hi Nadya
>> Are you saying that in the valid event of the textbox, you call a method in the form that launches a new form which contains the listbox? If so, could you call the listbox from the method of the original form?
>>
>>Just wondering,
>>Carmen
>
>Hi Carmen,
>
>I'm not sure, if I can reference the listbox on the same form (probably not). Here is the method of the form:
>
>*--------------------------------------------------------------------------
>* -- updated:rmm:10/01/01
>* -- && Updated:NN: 06/03/02 - added GroupBy clause
>* --	Validates the code keyed in, if incorrect, then pop up list will
>* --	display the correct codes
>*--------------------------------------------------------------------------
>lparameters tcTable, tcIndex, tcFldVal, tcSrchFld, tcCode, tcDesc, ;
>	tcControlSrc, tcListMsg, tcWhr, tcGroupBy
>*:lnCounter added to only display alert message if invalid code selected more than once
>
>if vartype(m.tcWhr)<>"C"
>   tcWhr = ""
>endif
>
>if vartype(m.tcGroupBy)<>"C"
>   tcGroupBy = ""
>endif
>
>local lnCounter, lcFilt
>lnCounter=0
>*:New Code to ensure accurate validation - create a loop for this code
>*:until a valid entry is selected
>do while .t.
>*:REV 12/27/01 SBB - need to add other condition when tcWhr is not empty
>	if !empty(m.tcWhr)
>*:REV 2/13/02 SBB IMPORTANT NOTE FOR USING THIS METHOD
>*:The where clause being passed is used for the locate below and
>*:for the SQL statement if the value is not found.  Note that the "Where" of the
>*:clause is not needed below but is needed in the SQL Statement.  Therefore, the
>*:"Where" term is also being passed as part of the lcWhr parameter
>*:For the case below, I am stripping out the first 6 chars ("Where ") to use
>*:the parameter as a filter condition.  If that fails, note that the entire
>*:lcWhr value is used in the SQL as it is required.  Therefore "where " must be passed
>*:as part of the value for this method to work properly.
>
>		lcFilt=substr(m.tcWhr,7)
>		select (m.tcTable)
>		locate for &tcSrchFld. = m.tcFldVal and &lcFilt
>	else
>		select (m.tcTable)
>		locate for &tcSrchFld. = m.tcFldVal
>	endif
>	if not found()
>*:Only display this alert on the second incorrect entry
>		lnCounter=m.lnCounter+1
>		
>		if not empty(m.tcFldVal) && Some code was selected
>
>			if m.lnCounter>1
>				do alert with 'Not a valid code. Please select from the list'
>			endif
>			
>			select &tcCode.+' -'+&tcDesc. as text, ;
>			    &tcCode. as CodeVal, &tcDesc. as Description ;
>				from (m.tcTable) ;
>				&tcWhr. ;
>				&tcGroupBy. ;
>				order by 3,2 ;
>				into cursor PopCursor
>				
>			do form LookupPop with m.tcControlSrc, m.tcListMsg, alltrim(m.tcFldVal) to tcFldVal
>*:Check the value that was selected
>*!*	           if not empty(m.tcControlSrc)
>*!*					tcFldVal=evaluate(m.tcControlSrc)
>		    		
>*:Pass the value selected to the lcFld and check again
>			select PopCursor
>			use
>		else && empty code
>		   exit	
>		endif
>	else
>		exit
>	endif	
>enddo
>return m.tcFldVal
>
>And here is textbox.Valid method:
>
>if this.DoValid
>	if thisform.CancelValidation()
>		return
>	endif
>	if not empty(this.value)
>		thisform.ValidateCode('deedtype','deedtype', this.value, ;
>			'deedtype.code','code','fullname', ;
>			'BldMstr.DeedType', ;
>			'Pop up List for Deed Type', ;
>			iif(thisform.LocState='MA','where inlist(code,"FD","LC","  ")', ;
>			'where not inlist(code,"FD","LC")'))
>		this.value = BldMstr.DeedType
>	endif
>endif
>
>The PopList form has nothing but the Listbox sized the same as form. Double click on the item closes the form and returns the chosen value.

Hi Nadya
While I couldn't incorporate all the ideas shown in the above sample, it was quite helpful, I used the same principle on a simpler level and it worked great!! Thank you!

Regards,
Carmen
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform