nate Posted January 19, 2007 Posted January 19, 2007 Object reference not set to an instance of an object. I have a control on my form called cbocontact. I call cbocontact.selecteditem.text and I get this wierd error. I have other cbo's that I use on this for the same exact way and get no errors. It is wierd. If I change the name I get the usually code corrections. Then I change the name back to it's original and the code errors or underlines are still there like the object doesnt exist. I tried deleting it and recreating it but It still causes the same error. Has anyone ever had this? Please Help! Quote Ignorance begins with I.
MrPaul Posted January 19, 2007 Posted January 19, 2007 No item selected It may not be that the cboContact itself is a null reference, but that the SelectedItem property is a null reference (no item selected). This is the default value for the control until an item has been selected. You should check that an item is selected first: If (cboContact.SelectedItem IsNot Nothing) Then 'Do something with cboContact.SelectedItem End If Good luck :) Quote Never trouble another for what you can do for yourself.
nate Posted January 19, 2007 Author Posted January 19, 2007 MrPaul, this is my line: If cboContacts.SelectedItem.Text > "" Then Recordset.Fields.Item("contact").Value = cboContacts.SelectedItem.Text yet if I select something I don't get an error. What is weird is I have another combo box that I run the same code for and don't select anything either but it goes through fine. I must be missing something. I use this all the time. Quote Ignorance begins with I.
mskeel Posted January 19, 2007 Posted January 19, 2007 You mentioned cboContact in the fist post and cboContacts in the second post...could it be as simple as a typo? Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.