Type mismatch when assigning to a combo box

odadgari

New member
Local time
Today, 19:15
Joined
Dec 3, 2012
Messages
5
I have a combo box named Color which may has values "Color-Matched", "Black" and "Natural". I want to make another fields (ColorLabel, ColorL, Colorb, Colora) visibe, if "Color-Matched" is selected in Color.
I wrote this code but it gives Run-time error '13': Type mismatch at second line:
Code:
Private Sub Form_Current()
    If Me.Color = "Color-Matched" Then
       Me.ColorLabel.Visible = True
       Me.colorL.Visible = True
       Me.colora.Visible = True
       Me.colorb.Visible = True
    Else
       Me.ColorLabel.Visible = False
       Me.colorL.Visible = False
       Me.colora.Visible = False
       Me.colorb.Visible = False
    End If
End Sub
Private Sub Color_AfterUpdate()
    If Me.Color = "Color-Matched" Then
       Me.ColorLabel.Visible = True
       Me.colorL.Visible = True
       Me.colora.Visible = True
       Me.colorb.Visible = True
    Else
       Me.ColorLabel.Visible = False
       Me.colorL.Visible = False
       Me.colora.Visible = False
       Me.colorb.Visible = False
    End If
End Sub
I think the way of assignig value to combo box is not correct. But I don't have any idea how to fix it.
 
The main problem I believe here is because your ComboBox display's the Text, but however has its column bound to another field.. Check your ColumnCount, BoundColumn, ColumnWidth, RowSource properties..

If your ColumnCount is 2, and BoundColumn is 1 and ColumnWidth is 0cm;3.07cm and RowSource is something like
Code:
SELECT tableName.IDFieldName, tableName.ColorFieldName FROM tableName
Then your code needs to change a little bit..
 
Hi,

Did you manage to display "Color-Matched" in the combo box?

In my case, the values are coming from a table column. All the other values are displaying fine except the one with the hyphen(-). This value displays as ####### .

Any ideas?
 
@ Princila - Do they appear fine after selection? If so try changing the width of the column a bit higher..
 
Hello,

Thank you! But; when I switched to datasheet view; I could see that the data in the column for that record displayed ######. Now, this data was coming from another linked table which had the right format (with the hyphen). So I changed the design of my current column. And now it displays fine. I have been getting many such errors after I converted to 2010 from 2003.
 
That is why I don't upgrade if it ain't broke. Then I wait for SP 2 before the upgrade.
 

Users who are viewing this thread

Back
Top Bottom