locked
A textbox is not being accessed through thisform.objects collection RRS feed

  • General discussion

  • SET DEVICE TO FILE test.txt 
    i=1 
    FOR EACH OBJ IN THISFORM.Objects
    	@prow()+1,0 say TRANSFORM(i)+' '+obj.name+'-->'+obj.baseclass 
    	i=i+1
    ENDFOR
    

    I have a form with text6 as an object (baseclass is textbox). But after running above code, all other controls get listed in file test.txt. but only text6 is missing in the list. what should be the cause?

    Output send to test.txt looks as follows;

    1 grdCashBank-->Grid
    2 Label1-->Label
    3 Lblmarathi1-->Label
    4 Lblmarathi2-->Label
    5 Edit1-->Editbox
    6 Lblmarathi3-->Label
    7 Text1-->Textbox
    8 Text2-->Textbox
    9 Text3-->Textbox
    10 Text4-->Textbox
    11 Kato-->Label
    12 Text5-->Textbox
    13 Combo1-->Combobox

    • Changed type RavindraPatilEditor Monday, May 30, 2016 7:38 AM It was actually a logical error
    Thursday, May 26, 2016 9:25 AM
    Answerer

All replies

  • Hi RavindraPatil,

    >> I have a form with text6 as an object (baseclass is textbox)

    Could you please show the definition of the “text6”?

    When you iterate through the collection “THISFORM.Objects”, does the count is right (contains “text6”)? Could you can see the “text6” in your form? Maybe you’d better pay attention to the process of adding the object.

    Best Regards,

    Albert Zhang

    Friday, May 27, 2016 1:48 AM
  • Strange, you also have no container, pageframe, etc where it could 'hide'.
    Is text6 perhaps added programmatically later?

    I've never seen Objects fail, so what else could be a reason? Do you perhaps overwrite a line with say?
    What is Thisform.Objects.Count?
    I have the strong suspicion prow() will be 0 first and you overwrite line 1.

    CREATE CURSOR crsObjects (cName c(128), cClass c(128))
    FOR EACH OBJ IN THISFORM.Objects
       INSERT INTO crsObjects VALUES (OBJ.Name, OBJ.baseclass)
    ENDFOR
    BROWSE

    Bye, Olaf.


    Olaf Doschke - TMN Systemberatung GmbH

    http://www.tmn-systemberatung.de


    Friday, May 27, 2016 4:43 AM
  • Dear Albert and Olaf, 

    I am very very sorry. I got my mistake.  Actually I did not expose THE WHOLE code in my post. If I had exposed it, you should find  the cause.

    I had a EXIT statement in my code that was causing the FOR loop termination before it reaches the object text6.

    Sorry to  bother you all.  My actual code was as follows;

    SELECT (THIS.recset)
    This.mycmdbtn01.Enabled = !this.isediting 
    This.mycmdbtn2.Picture = IIF(this.isediting,'Save.jpg','edit.jpg')  
    This.mycmdbtn2.ToolTipText = IIF(this.isediting,'saovh','roka^D-maQaIla badla')
    This.mycmdbtn3.Picture = IIF(this.isediting,'undo.jpg','Delete.jpg') 
    This.mycmdbtn3.ToolTipText = IIF(this.isediting,'badla r_', 'roka^D- r_')
    THISFORM.LBLMESGBAR.REFRESH  
    This.mycmdbtn2.originalpicture = IIF(this.isediting,'Save.jpg','edit.jpg')  
    This.mycmdbtn3.originalpicture = IIF(this.isediting,'undo.jpg','Delete.jpg') 
    this.mycmdbtn4.Enabled=!this.isediting AND !(RECCOUNT()=0 OR BOF())
    this.mycmdbtn5.Enabled=!this.isediting AND !(RECCOUNT()=0 OR BOF())
    this.mycmdbtn6.Enabled=!this.isediting AND RECCOUNT()#0
    this.mycmdbtn7.Enabled=!this.isediting AND !(RECCOUNT()=0 OR EOF())
    this.mycmdbtn8.Enabled=!this.isediting AND !(RECCOUNT()=0 OR EOF())
    *!*	 ENABLE OR DISABLE THE DATA ENTRY OBJECTS BASED ON ISEDITING OR NOT   
    FOR EACH OBJ IN THISFORM.Objects
    
    	IF INLIST(UPPER(OBJ.BASECLASS),'TEXTBOX','EDITBOX','OPTIONGROUP','CHECKBOX','LISTBOX','COMBOBOX','EDITBOX','GRID')
    		OBJ.ENABLED=This.isediting
    		IF obj.tabindex=1
    			IF UPPER(obj.baseclass)='OPTIONGROUP'
    				THIS.firstcontrol =OBJ.NAME+'.BUTTONS[1]'
    			ELSE	
    				THIS.firstcontrol=obj.name
    			ENDIF
                            EXIT    && THIS STATEMENT WAS THE CAUSE OF TE PROBLEM
    		endif
    	ENDIF
    	i=i+1
    ENDFOR
    IF ISREADONLY()
    	This.mycmdbtn01.Enabled = .f.
    	This.mycmdbtn2.Enabled = .f.
    	This.mycmdbtn3.Enabled = .f.
    ELSE
    	This.mycmdbtn2.Enabled = !(RECCOUNT()=0 OR EOF())
    	This.mycmdbtn3.Enabled = !(RECCOUNT()=0 OR EOF())
    	&& CHECK WHETHER THE RECORD IS ALLOWED FOR DELETION OR CHANGE
    	&& ......
    	*!*		This.mycmdbtn2.Enabled =.F.
    	*!*		This.mycmdbtn3.Enabled =.F.
    ENDIF
    IF this.isediting 
    	cmd='thisform.'+THIS.firstcontrol+'.setfocus()'
    	&cmd
    ENDIF
    	

    - Ravindra 


    Monday, May 30, 2016 8:00 AM
    Answerer