Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error in setting ComboBox RowSourceType:

Status
Not open for further replies.

hunterspot

Programmer
Jun 3, 2009
22
US
HI All
I have the following code. What I am trying to do is get new data into the cursor curplan. So I am assigning the rowsourcetype to value, delete the cursor and again assign the rowsourcetype to sql statement.
I am getting error 'Syntax Error' at the line where

this.cboplan.RowSourcetype = 3

I tried assinging the rowsource first and then rowsourcetype but still getting this error. Will you please let me know what am I doing wrong here and how to get this to work?

*******************
this.cboplan.RowSourcetype = 1
this.cboplan.RowSource = [ ]
IF USED([curPlan])
USE IN curPlan
ENDIF
this.cboplan.RowSourcetype = 3
this.cboplan.RowSource = [select descrip AS descript, VAL(descrip) AS desc, * from sg_plan where BETWEEN(thisform.proposalrecord.effdtereq,EffDate,TermDate) ORDER BY desc into cursor curPlan]

*this.cboplan.RowSourcetype = 3
*********************

Thanks in advance for your time.
 
desc is a key word for sorting descending, so you should not name the field you want to order by desc, that gives a syntax error of the sql, the parser is missing the field it should sort descending, it doesn't interpret ORDER BY desc as sorting by the field desc ascending.

That should be it. Otherwise I think THISFORM might not be doable in a sql rowsourcetype. You're better off doing the SQL yourself and then set the rowsourcetype to alias and rowsource to "curPlan".

Bye, Olaf.
 
When having my own problems with dynamically filled comboboxes, I was advised to keep RowSourcetype = 1 and fill the list "manually":

Code:
select descrip AS descript, VAL(descrip) AS desc, * from sg_plan where BETWEEN(thisform.proposalrecord.effdtereq,EffDate,TermDate) ORDER BY desc into cursor curPlan

WITH this.cboplan
	.clear
	SELECT curPlan
	SCAN
		.additem(descrip)		&& first field
		.list(.newindex,2) = desc	&& second field
		&& ...remaining fields similarly
	ENDSCAN
ENDWITH
For me, it worked even better than I hoped.

UPD: though yes, the DESC might be another reason for it to not work.
 
I agree with Kimed, except that the RowSourceType should be 0 if you are adding the items "manually".

That said, I would create a cursor first, and then use RowSourceType 2 or 6 to bind it to the combo. That might not solve your immediate problem, Hunterspot, but it would isolate the syntax error to the SQL Select, which should be easier to debug.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
If all you're trying to do is update the combo after refilling the cursor, you don't need any of this code. If the RowSourceType is 3-Query, and RowSource is the query, just call the combo's Requery method. It'll run the query again and repopulate the combo.

Tamar
 
this.cboplan.RowSourcetype = 1
this.cboplan.RowSource = [ ]
IF USED([curPlan])
USE IN curPlan
ENDIF
Select descrip AS descript, VAL(descrip) AS desc, *;
from sg_plan ;
where BETWEEN( thisform.proposalrecord.effdtereq, EffDate, TermDate) ;
ORDER BY 2 ;
into cursor curPlan

this.cboplan.RowSourcetype = 2
this.cboplan.RowSource = [curPlan]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top