Hello..!
i have an problem to connect a progress bar with listview object.P.bar working properly. bt i want to connect p.bar with ma sql database while m searching database.kindly help me where m i doin wrong..the code is below.

Private Sub cmdRFind_Click()
On Error Resume Next


Dim vLst As ListItem

    LstV1.ListItems.Clear

ProgressBar1.Min = 0
ProgressBar1.Max = d.RecordCount
ProgressBar1.Value = 0
    
    If d.BOF = True Then Exit Sub
       d.MoveFirst
       
       While Not d.EOF
       If d.Fields(0) = txtRWise.Text Then
       '--------------- TEXT BOX ------------------------
'==================================================

            Set vLst = LstV1.ListItems.Add(, , LstV1.ListItems.Count)
            vLst.SubItems(1) = d.Fields(0)      
            vLst.SubItems(2) = d.Fields(1)      
            vLst.SubItems(3) = d.Fields(2)      
            vLst.SubItems(7) = d.Fields(6)     
          
            LstV1.Refresh
End If

    For I = 0 To d.RecordCount
    ' Do nothing, but wait
    ' To show up the progress bar proceeding
    Next I

    ' Update the progress bar and percent label accordingly
    ProgressBar1.Value = ProgressBar1.Value + 1
    lblPercent.Caption = Int(ProgressBar1.Value * 100 / ProgressBar1.Max)
    lblPercent.Refresh

       d.MoveNext
            
       Wend
    
    LstV1.Refresh
    Me.txtRWise.Text = ""
    
End Sub

plz help me ..

Edited 6 Years Ago by __avd: Added [code] tags.

Your code is a little mixed up. Try the following -

If d.BOF = True Then Exit Sub
      Else
ProgressBar1.Min = 0
ProgressBar1.Max = d.RecordCount
ProgressBar1.Value = 0

Do While Not d.EOF
   If d.Fields(0) = txtRWise.Text Then
      'Whatever for the textboxes...
      'All the listview codes here...
         Else
      ProgressBar1.Value = ProgressBar1.Value + 1
      lblPercent.Caption = Int(ProgressBar1.Value * 100 / ProgressBar1.Max)

      d.MoveNext
   End If
Next

Has this solved your problem SkyVValker? If so, please mark this as solved, found at the bottom of this page, thanks.:)

no sir...i have already send u a complete code..!

this problem is still occured..!kindly help me out ..or tell me the other way .!

Skyvvalker, please paste the code that you have after trying my code. I need to see where your error is raised. What error message do you get and where does it occur. If it is not working, again, paste your code so I can alter it to a solution.:)

Private Sub cmdRFind1_Click()
On Error Resume Next


Dim vLst As ListItem

    LstV1.ListItems.Clear

   
            If d.BOF = True Then Exit Sub
                 Else
                ProgressBar1.Min = 0
                ProgressBar1.Max = d.RecordCount
                ProgressBar1.Value = 0
 
            Do While Not d.EOF

            If d.Fields(0) = txtRWise.Text Then
        '--------------- TEXT BOX ------------------------
        '==================================================

            Set vLst = LstV1.ListItems.Add(, , LstV1.ListItems.Count)
            vLst.SubItems(1) = d.Fields(0)      'Voucher No
            vLst.SubItems(2) = d.Fields(1)      'Date
            vLst.SubItems(3) = d.Fields(2)      'GRNo
          
            LstV1.Refresh
Else
      ProgressBar1.Value = ProgressBar1.Value + 1
      lblPercent.Caption = Int(ProgressBar1.Value * 100 / ProgressBar1.Max)
 
      d.MoveNext
   End If
Next
       
        'For I = 0 To 400000
        'ProgressBar1.Value = ProgressBar1.Value + 1
        'lblPercent.Caption = Int(ProgressBar1.Value * 100 / ProgressBar1.Max)
        'lblPercent.Refresh
        'Next I
 'Loop
 
    LstV1.Refresh
    Me.txtRWise.Text = ""
    

End Sub

there is two big problem ..
1st else without if
2nd Next without For....

This should solve your problem. Paste it as is under your cmdRFind1 click event. REMEMBER TO ADD YOUR DATABASE CONNECTION CODE AS WELL AS YOUR RECORDSET "d" OPEN STATEMENT IN THE CODE.:)

Dim vLst As ListItem
 
LstV1.ListItems.Clear
 
'#####Add your database open code here. d is obviously your
'recordset, open that as well here...

If d.BOF = True Then Exit Sub
        Else
    ProgressBar1.Min = 0
    ProgressBar1.Max = d.RecordCount
    ProgressBar1.Value = 0
 
    Do While Not d.EOF
 
    If d.Fields(0) = txtRWise.Text Then
        '--------------- TEXT BOX ------------------------
        '==================================================
 
        Set vLst = LstV1.ListItems.Add(, , LstV1.ListItems.Count)
        vLst.SubItems(1) = d.Fields(0)      'Voucher No
        vLst.SubItems(2) = d.Fields(1)      'Date
        vLst.SubItems(3) = d.Fields(2)      'GRNo
 
        '####Add the progressbar code here...
        ProgressBar1.Value = ProgressBar1.Value + 1
        lblPercent.Caption = Int(ProgressBar1.Value * 100 / ProgressBar1.Max)
 
        d.MoveNext
    '####Add the loop here to get all the records from d ...
    Loop
    '####Add the end if for your lstview here...
    End If
End If

'####Refresh your lstview...
LstV1.Refresh
End Sub

error is Else with out if..in line no 9..

Dim vLst As ListItem
 
LstV1.ListItems.Clear
 
'#####Add your database open code here. d is obviously your
'recordset, open that as well here...
d.Open ("SELECT TblFEE_KHM.*, SPINFKHM.STNAME, SPINFKHM.SFNAME, SPINFKHM.INWHICHCLASS, SPINFKHM.STUROLLNO, SPINFKHM.STUSECTION FROM TblFEE_KHM INNER JOIN SPINFKHM ON TblFEE_KHM.GRNO = SPINFKHM.GRNO Where (TblFEE_KHM.SecEnd = 0) ORDER BY TblFEE_KHM.VOUCHERNO"), Con
 
    If d.BOF = True Then Exit Sub
        Else
    ProgressBar1.Min = 0
    ProgressBar1.Max = d.RecordCount
    ProgressBar1.Value = 0
 
    Do While Not d.EOF
 
                If d.Fields(0) = txtRWise.Text Then
            '--------------- TEXT BOX ------------------------
        '==================================================

            Set vLst = LstV1.ListItems.Add(, , LstV1.ListItems.Count)
            vLst.SubItems(1) = d.Fields(0)      'Voucher No
            vLst.SubItems(2) = d.Fields(1)      'Date
            vLst.SubItems(3) = d.Fields(2)      'GRNo
            vLst.SubItems(4) = d.Fields(3)      'Year
   
          
            '####Add the progressbar code here...
        ProgressBar1.Value = ProgressBar1.Value + 1
        lblPercent.Caption = Int(ProgressBar1.Value * 100 / ProgressBar1.Max)
 
        d.MoveNext
    '####Add the loop here to get all the records from d ...
    Loop
    '####Add the end if for your lstview here...
    End If
End If
 
'####Refresh your lstview...
LstV1.Refresh

Change this part around -

d.MoveNext
'####Add the loop here to get all the records from d ...
Loop
'####Add the end if for your lstview here...
End If

d.MoveNext
    '####Add the loop here to get all the records from d ...
    End If
    Loop

if i change lyk this ..then i stuck the software..! i think there is smthing wrong with loop...!

Ok, we are going around in circles here.

Show me all the code under your command button AND the code you use to open your dataset where "d" is the recordset. I will then correct all code and re-post a 100% working solution for you.:)

Ok, we are going around in circles here.

Show me all the code under your command button AND the code you use to open your dataset where "d" is the recordset. I will then correct all code and re-post a 100% working solution for you.:)

i have already post the actual code.! and also mention that where m i open the recordset..! let me post the fresh code again..!

Private Sub cmdRFind1_Click()
On Error Resume Next


Dim vLst As ListItem
 
LstV1.ListItems.Clear
 
'#####Add your database open code here. d is obviously your
'recordset, open that as well here...
d.Open ("SELECT TblFEE_KHM.*, SPINFKHM.STNAME, SPINFKHM.SFNAME, SPINFKHM.INWHICHCLASS, SPINFKHM.STUROLLNO, SPINFKHM.STUSECTION FROM TblFEE_KHM INNER JOIN SPINFKHM ON TblFEE_KHM.GRNO = SPINFKHM.GRNO Where (TblFEE_KHM.SecEnd = 0) ORDER BY TblFEE_KHM.VOUCHERNO"), Con
 
    If d.BOF = True Then
    Exit Sub
        Else
    ProgressBar1.Min = 0
    ProgressBar1.Max = d.RecordCount
    ProgressBar1.Value = 0
 
    Do While Not d.EOF
 
                If d.Fields(0) = txtRWise.Text Then
            '--------------- TEXT BOX ------------------------
        '==================================================

            Set vLst = LstV1.ListItems.Add(, , LstV1.ListItems.Count)
            vLst.SubItems(1) = d.Fields(0)      'Voucher No
            vLst.SubItems(2) = d.Fields(1)      'Date

        ProgressBar1.Value = ProgressBar1.Value + 1
        lblPercent.Caption = Int(ProgressBar1.Value * 100 / ProgressBar1.Max)
 
       d.MoveNext
     
    '####Add the end if for your lstview here...
    End If
'####Add the loop here to get all the records from d ...
    Loop
End If
 
    
'####Refresh your lstview...
LstV1.Refresh

End Sub

Cool, I'll re-create your scenario and post a total solution during the course of today.:)

i have already post the actual code.! and also mention that where m i open the recordset..! let me post the fresh code again..!

By using the "!" is considered rude and impolite posting. Remember that we are here to help you by using our own FREE time. We do not get paid for this, so it is my time I'm offering to help YOU.:)

It's a pleasure to help.;)

See if the following will work for you. I think the problem lies with the records returned, hence the error in loading the prog. bar...

'#####Add your database open code here. d is obviously your
'recordset, open that as well here...
d.Open ("SELECT * FROM TblFEE_KHM WHERE TblFEE_KHM.SecEnd = 0 INNER JOIN SPINFKHM ON TblFEE_KHM.GRNO = SPINFKHM.GRNO ORDER BY TblFEE_KHM.VOUCHERNO"), Con

Have a look at the correct syntax to use when using INER JOIN in Sql HERE with some SELECT Statements as well.

Incorrect syntax near the keyword 'INNER'.

if i apply this query .this error is appeared

and if i replace where clause from the query then it shows the on this line with message

mss : Invalid property value

ProgressBar1.Max = d.RecordCount

Edited 6 Years Ago by SkyVValker: n/a

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