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
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