I don't have A2K7, so I couldn't open your dB. I have no idea what you are trying to do, so I made a form and a couple of list boxes to test your code. I put the code behind a button so I could run it when I wanted. This is what I found so far.
What are your list box names????
--------------------------------
In the sub Form_Current(), you have two list boxes named "ErrorCodeDescriptionList88" and "ErrorCodesandCorrections"
In the subs Sub ClearListBox(), you have two list boxes named "ErrorCodeDescriptionList88" and "ErrorCodesandCorrectionsList"
In the sub Sub Save_Record_Click(), you have two list boxes named "ErrorCodeDescriptionList88" and "ErrorCodesandCorrectionsList"
In the sub Sub clrList_Click(), you have two list boxes named "ErrorCodeDescription" and "ErrorCodesandCorrections"
In the sub Form_Current(), it looks like the list boxes are multi-select (because this of Me!ErrorCodeDescriptionList88.ItemData(iListItemsC ount))
Walking through the code, these two variables have a semi-colon:
Code:
sTemp = nz(Me!ErrorCodeDescriptionList88.Value, ";")
sTemp1 = nz(Me!ErrorCodesandCorrections.Value, ";")
If the list boxes are multi-select, you cannot get the values this way.
Next there is a line:
The list boxes are cleared of any selections before any other code uses the list boxes... ??
Next:
Code:
If StrComp(Trim(Me!ErrorCodeDescriptionList88.ItemData(iListItemsCount)), Trim(sValue)) = 0 Then
The variable "sValue" is not initalized, so it is NULL. Comparing a NULL with anything (including NULL) results in a NULL. So "NULL = 0" is FALSE.
And there are no items selected because of the call to "ClearListBox".
Then the Do - Loop....The first time through the the DO loop is OK.
The second time it goes into an endless look because "bFound" is never TRUE and "iListItemsCount" doesn't get reset - it keeps increasing. It starts off greater than Me!ErrorCodeDescriptionList88.ListCount.
Code:
Loop Until bFound = True Or iListItemsCount = Me!ErrorCodeDescriptionList88.ListCount
(this might be the cause of the error message)
That is as far as I got with the code.
--------------------------------------------------
These two lines should be at the top of every code page:
Code:
Option Compare Database
Option Explicit
-----
should the code be under Sub Form1
I wouldn't think so. But I don't know what the purpose of the code is for.
-----
If you use (in A2K3) the dot (Me.) notation instead of the bang (Me!), the compiler catches undeclared variables (if Option Explicit is at the top of the page).