I noticed a strange behaviour on combobox related to the SelectionChanged event. I'll try to explain what happens. I have 2 comboboxes: the first one (cmbBrand) is filled with BRAND values from a single column table, the second combobox (cmbModel) is filled with MODELS values form a two columns (BRAND, MODELS) table. At runtime, before entering the input routine, I call the Cleanup routine containing the following instructions
cmbBrand.SelectedIndex=-1
cmbModel.SelectedIndex=-1
During input, the program fires a cmbBrand_SelectionChanged (Index, Value) event that filters the two colum table based on the selected BRAND, and then cleanups and reloads the cmbModel in order to show only the Models of the selected Brand.
After input, the data are saved to a SQL table and then the program calls again the above Cleanup routine.
At that point the program raises an "Object reference not set to an instance of an object" and points to the cmbBrand.SelectedIndex=-1 instruction.
Commenting out the entire SelectionChanged routine, the Cleanup routine is called again and again without errors.
Here is the routine
Sub cmbBrand_SelectionChanged (Index, Value)
tblModel.Filter("MODEL_BRAND = " & SurrLastItem(Value))
cmbModel.SelectedIndex = -1
cmbModel.Clear
For k=0 To tblModel.RowCount-1
cmbModel.Add(tblModel.Cell("MODEL_NAME",k))
Next k
tblModel.Filter("")
End Sub
SurrLastItem returns a string enclosed between singles quotes.
Is anyone here that could give me please any help?
Many thanks
Mimmo
cmbBrand.SelectedIndex=-1
cmbModel.SelectedIndex=-1
During input, the program fires a cmbBrand_SelectionChanged (Index, Value) event that filters the two colum table based on the selected BRAND, and then cleanups and reloads the cmbModel in order to show only the Models of the selected Brand.
After input, the data are saved to a SQL table and then the program calls again the above Cleanup routine.
At that point the program raises an "Object reference not set to an instance of an object" and points to the cmbBrand.SelectedIndex=-1 instruction.
Commenting out the entire SelectionChanged routine, the Cleanup routine is called again and again without errors.
Here is the routine
Sub cmbBrand_SelectionChanged (Index, Value)
tblModel.Filter("MODEL_BRAND = " & SurrLastItem(Value))
cmbModel.SelectedIndex = -1
cmbModel.Clear
For k=0 To tblModel.RowCount-1
cmbModel.Add(tblModel.Cell("MODEL_NAME",k))
Next k
tblModel.Filter("")
End Sub
SurrLastItem returns a string enclosed between singles quotes.
Is anyone here that could give me please any help?
Many thanks
Mimmo