0
votes

I have a field called country with multi valued combo box. There are 10 values in the combo box. I need another field to be visible when a value from country field is selected otherwise invisible. I tried to use below VBA script but it gives an error as below

Error:
Runtime error 13
types incompatible

I am using the code below for which I get the above error:

Private Sub country_Click()
If country.Value = "11. OTHER" Then
   Me.country_txt.Visible = True
Else
   Me.country_txt.Visible = False
End If
End Sub

I am beginner to use MS Access. Can anyone please help.

1
Edit question to show combobox properties: RowSource, ColumnCount, ColumnWidths, BoundColumn, ControlSource, Should probably use AfterUpdate event instead of Click.June7
I am able to solve the issue by slightly changing the script. I used the below script and it works fine. Private Sub country_Click() If Me.country.Selected(10) Then Me.country_txt.Visible = True Else Me.country_txt.Visible = False End If End SubKiran Chapidi

1 Answers

0
votes

I am able to solve the issue by slightly changing the script. I used the below script and it works fine.

Private Sub country_Click() 
If Me.country.Selected(10) Then 
Me.country_txt.Visible = True 
Else Me.country_txt.Visible = False 
End If 
End Sub 

So here the issue got resolved when the value of the combo box was called as integer. In the list "11. OTHERS" is the 11th value. So Me.country.Selected(10) did the trick.