hi guyzz... i have more than 1000 datas in my tables i loaded it in the listview using function..

but i have problem in loading it.. it consume almost 9 second to load all in the listview...

i think it is in my coding.. i would like to minimize it. here my code.

Private Sub userPriceList1()
Set rsFltUser = Nothing
Set rsFltUser = OpenRS("Select branchcode,branchname,item_Number,item_name,balance_unitcost,balance_unit from itemlist order by item_name")

With rsFltUser
        If .RecordCount <> 0 Then
            .MoveFirst
            Do While Not .EOF
                Set lstitems = frmPOS.ListView2.ListItems.Add(1, , !branchcode & " - " & !branchname) 
                lstitems.SubItems(1) = IIf(IsNull(!item_Number), "", (!item_Number))
                lstitems.SubItems(2) = IIf(IsNull(!item_name), 0, !item_name)
                lstitems.SubItems(3) = FipoMethod(lstitems.SubItems(1), IIf(IsNull(!balance_unitcost), 0, !balance_unitcost))
                .MoveNext
            Loop
    End If
End With
End Sub
Private Function FipoMethod(itmNO As String, Optional SCost As Currency) As Currency
Dim rs2 As ADODB.Recordset
Set rs2 = Nothing
Set rs2 = OpenRS("select item_number,srp_value,srp_setup  from itemlist where item_number = '" & itmNO & "'")

With rs2
If .RecordCount <> 0 Then
If IsNull(!srp_value) = True Then !srp_value = 0
Select Case !srp_setup
Case 0 
    FipoMethod = Format(IIf(IsNull(!srp_value), 0, !srp_value), "standard")
Case 1
    FipoMethod = Format(SCost + (CCur(SCost) * ("." & Val(!srp_value))), "standard")
Case 2
    FipoMethod = Format(CCur(SCost) + CCur(!srp_value), "standard")
End Select
End If
End With
Set rs2 = Nothing
End Function

i tried already the byref and byval...

any suggestion wil be appreciated.

thx in advance

You can also try LockWindowUpdate to prevent the ListView from updating while the records are loaded.

Private Declare Function LockWindowUpdate Lib "user32" (ByVal hwndLock As Long) As Long

Call LockWindowUpdate (ListView1.hwnd)
'load the records
Call LockWindowUpdate (0&)

here my code and i thnk it nothing happen in loading..

Call LockWindowUpdate(ListView2.hwnd)
userPriceList1
Call LockWindowUpdate(0&)

any idea SCBWV

how to use the ADODB.RecordSet.GetRows () /??

Hi Jaasaria:

Try:
Call LockWindowUpdate(frmPOS.ListView2.hwnd)
userPriceList1
Call LockWindowUpdate(0&)

Hi,

I had a suggestion for you.

You are filling the Listview from table and function (which use table)

I suggest that you create new rs which will hold all your required data and then fill the listview from the rs.

hth

hi.. thx for ur reply guyzzz... i solved my problem..


i access only 1 table so i did..

i declare only one recordset to query the table and make the normal computation. without using function.

thxx and hope this thread will help also to other.

thx guyzz

hi.. thx for ur reply guyzzz... i solved my problem..
thx guyzz

Hi,

Glad you solved your problem.

I need 2 things from you if posiible

#1 mark this thread as solved
#2 post the time that you populate the listview in first approach and the second one.

TIA.

This article has been dead for over six months. Start a new discussion instead.