Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ComboBox Erratic Fatal Error behavior
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00806399
Message ID:
00807483
Views:
30
Nadya:

Nope, still there, I remove the combo box , create a new class base on a container that have a text box and a command bottom to simulate a combobox but the form still causing problem. this is the code that are in the init and active event.
the error is in the line 207
"		.controlsource=(thisform.r_flds[l_indx])"
*** INIT METHOD****
Parameters p_fldlist,p_headers,p_width,indx1,indx2,indx1name,indx2name,cw1,cw2,cw3,cw4,cw5,p_refresh, p_ndx1,p_ndx2

* PARAMTERS
*	p_fldlist	= passed field list
*	p_headers	= field descriptions
*	p_width		= width of form
*	indx1		= search field1
*	indx2		= search field2
*	indx1name	= search field1 caption
*	indx2name	= search field2 caption
*	cw1			= width of column1
*	cw2			= width of column2
*	cw3			= width of column3
*	cw4			= width of column4
*	cw5			= width of column5
*	p_refresh	= always refresh selection

* tah - 02/22/2002 per DRS removed this line of code so the lookup will always be grey.  If it is the
* same color as the other forms it can blend into the calling form.  If it is always grey it stands out
* from the calling form.
*!*	thisform.backcolor = mainmenu.background

* Store the column widths and the total of the column widths
thisform.r_fldLengths(6) = 0
for pCnt = 1 to 5
	pCW = "cw" + str(pCnt,1)
	thisform.r_fldLengths(pCnt) = &pCW
	thisform.r_fldLengths(6) = thisform.r_fldLengths(6) + &pCW
endfor

* tah - 03/13/2002 #271 If p_ndx1 or p_ndx2 is not numeric and/or is less than 1 ... set to 1
if type("p_ndx1") # "N" or p_ndx1 < 1
	p_ndx1 = 1
endif
if type("p_ndx2") # "N" or p_ndx2 < 1
	p_ndx2 = 1
endif

thisform.indexcol1 = p_ndx1
thisform.indexcol2 = p_ndx2

thisform.r_refresh = p_refresh

Thisform.OldExact = set("exact")
Set Exact off

Thisform.srchindex1 = ' '
Thisform.srchindex2 = ' '

Do CASE

Case !empty(indx1) and !empty(indx2)
	Thisform.srchindex1 = indx1
	Thisform.srchindex2 = indx2
	Thisform.sortby.option1.caption=indx1name
	Thisform.sortby.option2.caption=indx2name
	
	if jnLookUpOrder = 1
		Set order to (indx1)
	else
		Set order to (indx2)
	endif
	thisform.SortBy.value = jnLookUpOrder
	
*!*		Set order to (indx1)
	
Otherwise
	Thisform.sortby.option1.visible=.f.
	Thisform.sortby.option2.visible=.f.
	Thisform.lblsort.visible=.f.
Endcase

* tah - 06/21/00 removed the "go top" to remain at the spot in the file where you are.
*!*	Go top
Push KEY CLEAR
* tah - 06/21/00 removed the "on key label esc" so the user can press esc to exit.
*!*	On KEY LABEL ESC *

Thisform.WIDTH = p_width

* tah - 07/03/00 reset autocenter after form width is set center the form.
thisform.autocenter = .t.
	
Private ALL LIKE l_*
*Dimension THISFORM.r_flds[1]

Thisform.r_flds = ""
Thisform.r_alias = ALIAS()
If !EOF()
	Thisform.r_oldrec=RECNO()
Else
	Locate
	If EOF()
		* No records in table
		mainmenu.uanmessagebox('SM-5')
		* Set public variable .f. so menu items are active
		plLookUp = .f.
*!*			mainmenu.plLookUp = .f.
		* Exit without displaying the grid
		Return .f.
	Else
		Thisform.r_oldrec = RECNO()
	Endif
Endif

* If the table has a field named "FormName"...see if any records are able to be selected.
nnn = afields(FieldsArry)
nnn = ascan(FieldsArry,"FORMNAME")
if nnn # 0
	rrr = recno()
	count to x for empty(FormName)
	go rrr
	if x = 0
		* No records able to be selected.
		mainmenu.uanmessagebox("SM-3")
		* Set public variable .f. so menu items are active
		plLookUp = .f.
*!*			mainmenu.plLookUp = .f.
		* Exit without displaying the grid
		Return .f.
	endif
	thisform.r_FormName = .t.
endif

l_firstchr = 1
l_lastchr = 1
l_numfld = 0
l_fldlen = 0
Do WHILE l_lastchr <= LEN(p_fldlist)
	l_numfld = l_numfld+1
*	Dimension THISFORM.r_flds[l_numfld]
	If AT(",",p_fldlist,l_numfld) > 0
		l_lastchr = AT(",",p_fldlist,l_numfld)-1
	Else
		l_lastchr = LEN(p_fldlist)+1
	Endif
	Thisform.r_flds[l_numfld] = ;
		ALLTRIM(SUBSTR(p_fldlist,l_firstchr,l_lastchr-l_firstchr+1))

	If AT(",",p_fldlist,l_numfld)>0
		l_firstchr=AT(",",p_fldlist,l_numfld)+1
	Else
		l_firstchr = LEN(p_fldlist)
	Endif

	l_fldname = THISFORM.r_alias+"."+THISFORM.r_flds[l_numfld]
	Do CASE
	Case type("&l_fldname") = "N" 
		lcsub = ALLTRIM(STR(&l_fldname))
		l_fldlen = l_fldlen + LEN(lcsub)
		ThisForm.grdsearch.columns(l_numfld).removeobject('_editbox1')
	Case type("&l_fldname") = "L"
		lcsub = IIF(&l_fldname,"T","F")
		l_fldlen = l_fldlen + 1
		ThisForm.grdsearch.columns(l_numfld).removeobject('_editbox1')
	Case type("&l_fldname") = "C" or type("&l_fldname") = "M" 
		l_fldlen = l_fldlen + LEN(&l_fldname)
		ThisForm.grdsearch.columns(l_numfld).currentcontrol='_editbox1'
	case type("&l_fldname") = "U"
		dimension Error_Arry(1)
		Error_Arry(1) = l_fldname
		clear typeahead
		MainMenu.UANMessageBox("SM-22", @Error_Arry)
		return .f.
	case type("&l_fldname") = "D"
		ThisForm.grdsearch.columns(l_numfld).removeobject('_editbox1')
	Endcase
Enddo
Thisform.r_numfld = l_numfld
Thisform.r_fldlen = l_fldlen

Dimension a_head[1]
a_head = ""
l_firstchr = 1
l_lastchr = 1
l_numfld = 0
l_headlen = 0
Do WHILE l_lastchr <= LEN(p_headers)
	l_numfld = l_numfld+1
	Dimension a_head[l_numfld]
	If AT(",",p_headers,l_numfld)>0
		l_lastchr=AT(",",p_headers,l_numfld)-1
	Else
		l_lastchr = LEN(p_headers)+1
	Endif
	a_head[l_numfld]=ALLTRIM(SUBSTR(p_headers,;
		l_firstchr,l_lastchr-l_firstchr+1))
	If AT(",",p_headers,l_numfld)>0
		l_firstchr=AT(",",p_headers,l_numfld)+1
	Else
		l_firstchr = LEN(p_headers)
	Endif
Enddo

With THISFORM.grdsearch
	.RECORDSOURCE=THISFORM.r_alias
	.COLUMNCOUNT = l_numfld
	.WIDTH = THISFORM.WIDTH
	.HEIGHT=THISFORM.HEIGHT-60
Endwith

l_grdwidth=thisform.grdsearch.width-30
For l_indx = 1 to l_numfld
	l_col="thisform.grdsearch.column"+;
		ltrim(str(l_indx))
	With &l_col
		.controlsource=(thisform.r_flds[l_indx])
		l_fldname=thisform.r_alias+"."+thisform.r_flds[l_indx]
		Do CASE
		Case type("&l_fldname") = "N"
			lcsub = ALLTRIM(STR(&l_fldname))
		Case type("&l_fldname") = "L"
			lcsub = IIF(&l_fldname,"T","F")
		Case type("&l_fldname") = "C"
			lcsub = &l_fldname
		Endcase
		mylen = 'cw' + str(l_indx,1)
		If len(lcsub) > &mylen
			Len(lcsub)
*!*				.width=round((len(lcsub)/l_fldlen)*l_grdwidth,0)
		Else
			.width=&mylen
*!*				.width=round((&mylen/l_fldlen)*l_grdwidth,0)
		Endif
		.readonly = .t.
	Endwith
	l_head = l_col+".header1"
	With &l_head
		.caption = (a_head[l_indx])
	Endwith
Endfor



* Scroll down 3 lines so the initial selection is not at the top of the grid.
****Activate Method******
* Do not want Activate class code to run in pLookUp
a=1
b=2
Thisform.caption =  "Search: "
thisform.setall('tabstop',.f.,'commandbutton')
thisform.setall('fontbold',.t.,'commandbutton')
*!*	dodefault()
*!*	mainmenu.wincount = mainmenu.wincount -1
*!*	*** decrease the windows count 
Hope you find a clue
Gregorio J. Placeres
IT Analyst
Uniform Accounting Network
Auditor of State of Ohio
88 East Broad Street
P.O. Box 1140
Columbus, Ohio 43216-1140

Tel. 614-728-4694

Gregorio_J@MSN.COM

http://www.gjpproductions.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform