Tom Keatley
tom.p at piedpiper.com.au
Thu May 4 01:47:37 CDT 2006
Hi Stuart.... Thanks for the hand with this .....I think the end is in sight. I now have the code below that runs fine as is, my data mismatch problem turned out to be...... I had headers turned on in the listbox (i) and of course its an integer so after I turned headers on it ran without errors. The only problem is the list has only ONE line selected and that line is the first in the sequence (I assume the LAST to be processed) The box IS set to multiselect as I can select multiple values manually . I have put the results of the debug below the code.... Dim intI As Integer Dim i As Integer Dim strIDValue As String Dim lngCurrentValue As Long strIDValue = "13772,13773,13771" '' strIDValue = strIDValue & "," 'to pick up the last value in the loop below Do lngCurrentValue = Val(strIDValue) 'get the first number strIDValue = Mid$(strIDValue, InStr(strIDValue, ",") + 1) 'get rid of the first number''''' For intI = 0 To Me!listcon1.ListCount - 1 If Me!listcon1.ItemData(i) = lngCurrentValue Then Me!listcon1.Selected(i) = True End If Debug.Print Me!listcon1.ItemData(intI) & " - " & lngCurrentValue 'Debug.Print str(lngCurrentValue) Next intI Loop Until InStr(strIDValue, ",") = 0 13772 - 13772 13771 - 13772 13773 - 13772 7125 - 13772 7124 - 13772 7126 - 13772 7128 - 13772 13772 - 13773 13771 - 13773 13773 - 13773 7125 - 13773 7124 - 13773 7126 - 13773 7128 - 13773 13772 - 13771 13771 - 13771 13773 - 13771 7125 - 13771 7124 - 13771 7126 - 13771 7128 - 13771 On 4 May 2006 at 12:36, Tom Keatley wrote: > Hi Stuart.... > > Hopefully the last one.... > > I have downloaded the code you suggested at tektips and have > installed it in a module within the database but now get a compile > error with the message "cant Assign to an array" .... It must be the > syntax? I must admit this little wall is getting higher for me and I > am considering finding another way. > Haven't got a copy of A97 handy to check it it. > For some reason the other code (without split) you did for me is > giving me a type mismatch error so I made strCurrentValue into a > string and the code appeared to run giving all the correct numbers and > iterating through the listbox (in the debug window) but no lines were > selected.... > > can you shed any light? Looks like your ItemData is not numeric. Try printing out Debug.Print Me!listcon1.ItemData(intI) & " - " & strCurrentValue in the loop to see what you are actually comparing. Let us know what you get.