Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stupid combobox

Status
Not open for further replies.

FunnyGuy

Technical User
May 26, 2003
19
CA
Hi there,

I am trying to clear a combobox that I have loaded at the beginning of my form. My combo box consists of various items from a table. I am able to load my info into the combo box, no problem.
When the user clicks on a button, I am trying to clear the combo box, but for some reason I cannot clear the damn box!
If I am doing this wrong, please let me know or if you have any advice, any would be appriciated.

'code that starts in the form load event

If IsNull(txtC1) = True Then
Else
cmbContactNames.AddItem txtC1
End If

If IsNull(txtC2) = True Then
Else
cmbContactNames.AddItem txtC2
End If

If IsNull(txtC3) = True Then
Else
cmbContactNames.AddItem txtC3
End If

'Now on my click button event I thought I could do this

cmbContactNames.Clear

Any ideas?

Thanks
 
Hi Skip,

I have that in my third last thread line....believe it or not, it is not working and that is what I cannot understand. The error that comes up is:

Compile error:
Method or data member not found

Any reasons as to why this isn't working?
 
Here's some code I used in CommandButton_Click...
Code:
    With ComboBox1
        .Clear
        If TextBox1.Text <> &quot;&quot; Then _
            .AddItem TextBox1.Text
        
        If TextBox2.Text <> &quot;&quot; Then _
            .AddItem TextBox2.Text
    End With
:)

Skip,
Skip@TheOfficeExperts.com
 
My code is stopping at the .Clear method and giving me the same error still. I am baffed! I must have something wrong somewhere....
 
Yes, this is crazy. I just started a brand new db and placed a combobox on a form. The combobox is called cmbTest and I placed this code in the form load event:

cmbTest.AddItem &quot;T&quot;
cmbTest.AddItem &quot;D&quot;

Now I added a button and called it cmdTest. I placed this code in the click event:

cmbTest.Clear

When I ran the form I had an error telling me to change the combobox row source type to Value List. After I changed that, when the form was run, the values came up no problem. As soon as I click on the button, the same error from before (compile error) comes up!

I am quite confused with this. Can you create a db with a combobox in it (make sure it works) and send it to me via email? If it works, then it must be something else in the program...a reference or something.

shaun@kenlindesign.com


 
Geez, sorry, I thought I was in the Access VB forum! This is an acual Access form, not a userform from VB. I have used the .clear before in VB and it has worked but I cannot get it to work here.
Any ideas at all? Thanks for all your help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top