coding a value for a dropdown list field (1 Viewer)

grenee

Registered User.
Local time
Yesterday, 16:11
Joined
Mar 5, 2012
Messages
210
Good Day All,

My field "Categories" acquired its values from a dropdown listbox. However I want, in some cases, to code in a value known to be in the dropdown listbox. Although the values entered in the code corresponds with what is in the dropdown list I am getting an error message which says: "the Value you entered isn't valid for this field"

Here is the code line:
Code:
 Me.Categories = "Lamp Shades"

I would be grateful for any assistance in this matter
 
Last edited:

jdraw

Super Moderator
Staff member
Local time
Yesterday, 19:11
Joined
Jan 23, 2006
Messages
15,379
Please tell us more about your set up -the table(s) involved and the Form involved.
Readers need some context to understand your issue.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 07:11
Joined
May 7, 2009
Messages
19,229
if your combobox has more than one
column and the bound column (column 1)
is hidden, and only showing the column 2
(the descriptive name). then it would fail.
you must search the combo for the value:

Dim i As Integer
For i = 0 To Me.Combo0.ListCount - 1
If Me.Combo0.Column(1, i) = "Lamp Shades" Then
Me.Combo0 = Me.Combo0.ItemData(i)
Exit For
End If
Next
 

Users who are viewing this thread

Top Bottom