Ahsan Amin


I have to compare a db value with the values/listitems of the combo box control. When found it shoudl be selected. At the time i am tying with this

thisform.cboCourse.Value = a_Courses.CourseName

does not work




Re: Combo Value

fvp4ever


Did you tried Alltrim() (I mean for both sides)

you should have both sides in same cases try upper() and lower()






Re: Combo Value

Ahsan Amin

i have to compare a table value with each item of combobox

if found than selected = .t.






Re: Combo Value

Ahsan Amin

i have succeeded in finding the list item from combobox control i am using this code

LOCAL nCnt
FOR nCnt = 1 TO thisform.cboCourse.ListCount
IF thisform.cboCourse.List(nCnt) = ALLTRIM(a_Courses.CourseName)
thisform.cboCourse.Selected(nCnt) = .t.
MESSAGEBOX(thisform.cboCourse.Value + " " + a_Courses.CourseName)
thisform.cboCourse.Value = ALLTRIM(a_Courses.CourseName)
ENDIF
ENDFOR

Now i want this list item to appear on top combo





Re: Combo Value

MarciaAkins

Ahsan Amin wrote:

I have to compare a db value with the values/listitems of the combo box control. When found it shoudl be selected. At the time i am tying with this

thisform.cboCourse.Value = a_Courses.CourseName

does not work

Is there some reason that you do not just set the combo's ControlSource to be a_Courses.CourseName






Re: Combo Value

Markish

Hi,

Setting the combo's datasource to a_courses.coursename should solve your issue.

Best regards,

Markish






Re: Combo Value

CetinBasoz

Do not set controlsource but the value or listindex to recno() if rowsource is an alias type. No need for a loop.