List Box Transfer - Overflow error

Alan R

Registered User.
Local time
Today, 21:14
Joined
Sep 11, 2006
Messages
70
Hi,

I am attempting to implement the 'Retrieve selected items in a multiple selection box' contained within the Microsoft Knowledge Base Article 827423 to allow a multiple selection and passing of selected data to a text box.

Initilly it seemed to work really well, but for some reason it has stopped and gives me an Overflow Error '6' and highlights the following line of code when i 'debug'

Private Sub Form_Current()
Dim oItem As Variant
Dim bFound As Boolean
Dim sTemp As String
Dim sValue As String
Dim sChar As String
Dim iCount As Integer
Dim iListItemsCount As Long

sTemp = Nz(Me!SelectedDirectives.Value, " ")
iListItemsCount = 0
bFound = False
iCount = 0

Call clearListBox

For iCount = 1 To Len(sTemp) + 1
sChar = Mid(sTemp, iCount, 1)
If StrComp(sChar, ",") = 0 Or iCount = Len(sTemp) + 1 Then
bFound = False
Do
If StrComp(Trim(Me!DirectivesList.ItemData(iListItemsCount)), Trim(sValue)) = 0 Then
Me!DirectivesList.Selected(iListItemsCount) = True
bFound = True
End If
iListItemsCount = iListItemsCount + 1
Loop Until bFound = True Or iListItemsCount = Me!DirectivesList.ListCount
sValue = ""
Else
sValue = sValue & sChar
End If
Next iCount
End Sub

I am using this facility to allow th euser to select a number of EU Directives that a piece of equipment has been tested against and this may be 1, 2 or more such directives.

I have implemented the 'Clear List' function by calling the function at appropraite times i.e. saving the record, next / previous record etc.

Can anybody shed any light on why this should start happening now?

Is there a more efficient / easier way of achieving this selection and transfer to a text box.

Many Thanks

Alan
 
sounds like your number exceeded 2 billion, but that sounds silly doesn't it!

if it happens every time
i would put a breakpoint on or after call clearlistbox, and trace the execution a line at a time
 
Gemma,

Thanks for the response.

Will need to read up on how to carry out your suggestion - never done that before.

What surprises is that it can give an overflow error when there are only 3 items in the list box and only about 5 test records containing either 1,2 or 3 entries in the associated text box/table.

Alan
 
i would think there's an error in your code somewhere

click in the left margin at the first statement. this will set a brown blob (a breakpoint) - you can toggle it off and on by clicking it

when the code runs it will pause at that point.

use F8 to sdtep through a line at a time. hover your mouse over any variable to see how the variable is changing. Its a really powerful and useful technique for stuff like this
 
Found It!!

Gemma,

Found the cause of the problem. There was nothing wrong with the code being highlighted, the error / typo lay in the coding attached to the OnClick of the 'Transfer Selection' button. All seems to be working fine (for) now.

Many thanks for taking the time to respond to question.


Regards

Alan
 

Users who are viewing this thread

Back
Top Bottom