Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (edited)

*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?

but this works the first time through' date=' so I don't think that's it.[/quote']

 

 

I'm leaving the condensed version of the code if anyone is interested, or Mods you can delete this post if you want.

 

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:

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!

Edited by alreadyused

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...