Progress Bar Problems

Howlsta

Vampire Slayer
Local time
Today, 12:23
Joined
Jul 18, 2001
Messages
180
I'm doing an export program in VB to export records into Access. I want to add a progress bar as there could be a large number of records. Here's what I've got currently:

pbrExport.Min = 0
pbrExport.Max = mrecData.RecordCount
intCounter = 0

'Do... loop to Add some records to text file

intCounter = intCounter + 1
pbrExport.Value = intCounter
mrecData.MoveNext
Loop Until mrecData.EOF

The problem seems to be that the recordCount is storing -1 as it's value. I've had this problem before, but solved it using OpenKeyset.

However, this time i'm using ADO and don't know how to sort out the problem.

#If ccSQL Then
Set mrecData = mADOConnection.Execute _
("SELECT * FROM [AttendantCircumstances")
#Else
Set mrecData = mADOConnection.Execute _
("SELECT * FROM [Attendant Circumstances]")
#End If

Does anyone have any ideas or is there a better way of doing the progress bar?

Rich
 
I solved this problem now, by opening a temporary recordset, I had to do this because apparently you can't set the cursor type in the circumstances of the code above.

Here's what I did instead

Set rsTemp = New ADODB.Recordset
rsTemp.Open "SELECT * FROM [Attendant circumstances]", mADOConnection, adOpenStatic, adLockReadOnly
pbrExport.Min = 0
pbrExport.Max = rsTemp.RecordCount
intCounter = 0
rsTemp.Close

thanks to those of you who looked at my problem.

Rich
 

Users who are viewing this thread

Back
Top Bottom