alreadyused
Regular
- Joined
- Jan 13, 2006
- Messages
- 69
*RESOLVED* - runtime clear combobox and reload - breaks
I just figured out what's happening. I have cboRev which is populated based on cboUnit, just like cboUnit based on cboJob.
So when I'm setting the text on cboUnit, the change event for cboUnit is being called. So now I just have to figure out what to do with that and I'm golden.
This should have been my clue; i have a boolean that tells the change events not to run on form load. Anyone know a cleaner way of doing that?
I'm leaving the condensed version of the code if anyone is interested, or Mods you can delete this post if you want.
I just figured out what's happening. I have cboRev which is populated based on cboUnit, just like cboUnit based on cboJob.
So when I'm setting the text on cboUnit, the change event for cboUnit is being called. So now I just have to figure out what to do with that and I'm golden.
This should have been my clue; i have a boolean that tells the change events not to run on form load. Anyone know a cleaner way of doing that?
me said:but this works the first time through, so I don't think that's it.
I'm leaving the condensed version of the code if anyone is interested, or Mods you can delete this post if you want.
ME said:I have _objJL (visible to the class) that holds objJob that holds objUnit.
I am taking the text in cboJob1, finding the corresponding objJob stored in _objJL, and want to
list it's children in cboUnit1.
I want to populate cboUnit1 based on cboJob1; the first time I do this, all works fine; but
when I run it on a change event, it breaks.
The error is "Object reference not set to an instance of an object."
The sequence is on form_load, the cbos are cleared, populated, and then selected based on an
initial selection (from the form calling this form)/
On the cboJob1_SelectedValueChanged I call the same routine, so clear the cbo, populate and
select.
I wonder if it's a failure on my part with my objects objJob and objUnit? I never set them as
New objects, but instead set them equal to objects stored in the parent object's collection;
but this works the first time through, so I don't think that's it.
My guess is something I'm doing on selecting the correct item; I am not setting indexes on the
combobox, just simply using the text.
It is breaking here:
Visual Basic:With Me.cboUnit1 '... If Not tmpUnit is NOthing Then 'Breaks right here on subsequent runs; 'have tried Me.cboUnit1.Text, and also cboUnit1.Text .Text = tmpUnit.Name '... End If '... End With
Thanks in advance!
Last edited: