Scooterbug
Registered User.
- Local time
- Today, 10:43
- Joined
- Mar 27, 2009
- Messages
- 853
Well, I hate to see ppl give up....so I did a quick test. I setup a listbox on a form. I used a value list with the following data: Test One, Test Two, Test Three, Test Four. I then put in a text box. I added the following code to the before update of the text box:
Now, if the Value list is just the text, i always equals 0 using the code above. Dunno why. I'm sure Bob knows. If I use some kind of numeric ID number, i equals the correct number of entries. However, I am assuming that the text box that you are comparing to isn't a number, it's text.
If that is the case, you are comparing Apples to Oranges. I am guessing that the list box is bound to a table or query where the bound column is the ID number. Since the Text box you are trying to validate contains text and the listbox's bound column is an ID, they will never match.
Without seeing your database...my assessment may be wrong...so take with a grain of salt.
Your list box's bound
Code:
Dim i As Integer
'Me.cmbasset.Value = Me.cmbstag.Column(1)
Debug.Print Me.List115.ItemsSelected.Count
For i = 0 To Me.List115.ItemsSelected.Count - 1
If Me.Text117 = Me.List115.ItemData(Me.List115.ItemsSelected(i)) Then
MsgBox ("This laptop is already on loan")
Me.Text117.Value = ""
Me.Text117.SetFocus
Else
End If
Next
Now, if the Value list is just the text, i always equals 0 using the code above. Dunno why. I'm sure Bob knows. If I use some kind of numeric ID number, i equals the correct number of entries. However, I am assuming that the text box that you are comparing to isn't a number, it's text.
If that is the case, you are comparing Apples to Oranges. I am guessing that the list box is bound to a table or query where the bound column is the ID number. Since the Text box you are trying to validate contains text and the listbox's bound column is an ID, they will never match.
Without seeing your database...my assessment may be wrong...so take with a grain of salt.
Your list box's bound