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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combobox ListIndex problem... 1

Status
Not open for further replies.

Neil Toulouse

Programmer
Mar 18, 2002
882
GB
Hi there!

I have gone a bit brain-dead this week as I am moving house so am unable to see where my issue is with the following problem!

Basically I have a form from which a user selects a folder (clicks on a button to navigate to the folder) which contains their reports. I then build up a combobox with the filenames of these reports in the following manner:

Code:
	*** Populate the combo with the name of all the RPTs in the selected directory
	IF !EMPTY(.txtFolder.VALUE)
		.cboreport.value = ' '
		
		lnCount = ADIR( laFiles, ALLTRIM(.txtFolder.VALUE) + "*.RPT" )
		IF lnCount = 0
			FOR lnI = 1 TO .cboReport.LISTCOUNT
				.cboReport.REMOVEITEM(1)
			ENDFOR
			.cboReport.VALUE = ''
			.edtTables.VALUE = ''
			RETURN
		ENDIF
		
		FOR lnI = 1 TO lnCount
			.cboReport.ADDITEM(PROPER(JUSTSTEM(laFiles(lnI,1))))
		ENDFOR


		*** Initially select the first report in the combo

        .cboReport.listindex = 1

        *** CODE TO DO SOMETHING WITH THE FIRST FILE IN THE LIST (.cboReport.Value) ***

	ENDIF

This works fine the first time round, but if the user then selects a different folder, triggering the above code again, .cboReport.Value is still the previous selected item from the first round!

The code then falls over as it can't find the old file in the new folder (correct).

I have a feeling it is something to do with the way I am forcing a value into the combobox with the LISTINDEX property = 1.

Does the combo hold the values for those items that have been removed? Is there a better/easier way for me to force the first element in the list to be the value of the combo to get this to work?

TIA
Neil

I like work. It fascinates me. I can sit and look at it for hours...
 
Hi Neil,

Instead of:
.cboreport.value = ' '
how about:
.cboreport.clear()

Regards,

Mike
 
Excellent Mike, that's done the trick :)

Have a star!

Neil

I like work. It fascinates me. I can sit and look at it for hours...
 
Hi Neil,

Glad you got it working. And Thanks!

Regards,

Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top