Gustav Brock
Gustav at cactus.dk
Wed Nov 8 04:34:39 CST 2006
Hi Shamil Very good. Of course, if the data aren't static a static array (or static collection or static recordset) cannot be used or, at least, it has to be refilled/required somehow when the underlying data changes. A global variable can be used which is set when data change and reset after the array is refilled. To watch how intensely a callback function is called, insert a debug line like this: Public Function OrderListPrint( _ ctl As Control, _ ID As Long, _ row As Long, _ col As Long, _ Code As Integer) Static astrPrint(1 To 7) As String Dim varValue As Variant Dim lngCount As Long Select Case Code Case acLBInitialize ' Global variable can be set to force a refill of array. If Len(astrPrint(1)) = 0 Or pbooRefill = True Then ' Fill array. For lngCount = 1 To 7 astrPrint(lngCount) = GetMsg("SaleId90" & lngCount) Next ' Reset global variable. pbooRefill = False End If varValue = True Case acLBOpen varValue = Timer Case acLBGetRowCount varValue = 7 ' Rows. Case acLBGetColumnCount varValue = 2 ' Columns. Case acLBGetColumnWidth varValue = -1 ' Column width. Case acLBGetValue If col = 0 Then varValue = row + 1 ElseIf col = 1 Then varValue = astrPrint(row + 1) End If Case acLBGetFormat ' Format the data. ' varValue = strFormat Case acLBEnd ' Do something when form with listbox closes or ' listbox is requeried. End Select Debug.Print code, varValue OrderListPrint = varValue End Function /gustav >>> shamil at users.mns.ru 07-11-2006 19:29:37 >>> Drew and Gustav, I will try to "cook" a sample where static array caching can't be used and then a combo could result in datasheet form scrolling slowdown... If I will not come with such a sample here in a month (no time currently to trick around it) then the case I mentioned was the case of the bad callback function design. BTW, in MS Access online help is written: "The number of times your user-defined function is called for acLBGetValue and acLBGetFormat to get list entries and to format strings varies depending on the number of entries, the user's scrolling, and other factors." "The user's scrolling" they say - be aware of that when using callback functions - this is what I meant first of all... -- Shamil