Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Flexgrid and displaying records 1

Status
Not open for further replies.

hpicken

Technical User
Apr 12, 2001
142
AU
firstly, thanks in advanced for any help antone can give me.

I trying to develop a VB front to a access db.

I have the searching sorted out thanks to SDuke As he found out I'm coming from a VBA background.

I'm now playing with a progress bar. However when the progressbar gets to 100% the form takes a further 3min on 32K records to display them. In other words the progress bar take 10sec to display 100% and the form takes 3min to display them.

What am I doing wrong? Code piece follows

Code:
    Set db = OpenDatabase(strPath & DBName, False, True)
    strSQL = "SELECT ID, Name, ListType, EDate, Register FROM tblSearchList"
    Set rsNames = db.OpenRecordset(strSQL, dbOpenSnapshot, 0, dbReadOnly)
    rsNames.MoveFirst
    rsNames.MoveLast
    numRecs = rsNames.RecordCount
    MSFlexGrid1.BackColorSel = &HC0FFFF
    Screen.MousePointer = vbHourglass
    'make the search
    ProgressBar1.Visible = True
    txtUpdatePercent.Visible = True
    ProgressBar1.Value = 1
    rsNames.MoveFirst
    MSFlexGrid1.Rows = 2
    If Not (rsNames.BOF And rsNames.EOF) Then
        Do While Not rsNames.EOF
            MSFlexGrid1.TextMatrix(MSFlexGrid1.Rows - 1, 0) = rsNames.Fields(0).Value
            MSFlexGrid1.TextMatrix(MSFlexGrid1.Rows - 1, 1) = rsNames.Fields(1).Value
            MSFlexGrid1.TextMatrix(MSFlexGrid1.Rows - 1, 2) = rsNames.Fields(2).Value
            MSFlexGrid1.TextMatrix(MSFlexGrid1.Rows - 1, 3) = rsNames.Fields(3).Value
            MSFlexGrid1.TextMatrix(MSFlexGrid1.Rows - 1, 4) = rsNames.Fields(4).Value
            MSFlexGrid1.Rows = MSFlexGrid1.Rows + 1
            rsNames.MoveNext
            If ProgressBar1.Value < 100 Then
                ProgressBar1.Value = ProgressBar1 + Int(((MSFlexGrid1.Rows / rsNames.RecordCount) * 100))
                txtUpdatePercent.Text = Str(Int(ProgressBar1.Value)) & "%"
                txtUpdatePercent.Refresh
            End If
        Loop
    End If
    
   'show number of records found
    Me.Caption = "Register List - Showing " & CStr(rsNames.RecordCount) & " Records"
    
    strSQL = ""
    ProgressBar1.Visible = False
    txtUpdatePercent.Visible = False
    txtGetSurname.Text = ""
    Screen.MousePointer = vbNormal
 
Two things:

1- I cant's see where you set the maximum value of the progressbar?
2- I'd set the maximum value of the Progressbar to the recordcount property of the recordset you're using and then on each movenext increase the progressbar by 1.

Greetings,
Rick
 
So the progress bar is not limited to 100(%)?

If I have 32K records then I should set the max to 32K? Is it that simple?

 
If you check the progressbar in the objectbrowser, you'll see that it has a "Max" property of datatype "single". This means its value surely can be 32k (you'll first have to set it to that though). It is NOT a 100% counter.

Greetings,
Rick
 
Thanks Rick. I'll get this app going even if it drives me nuts!

Cheers
Howard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top