Neil Toulouse
Programmer
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:
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...
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...