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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem using Getrows if no records exist

Status
Not open for further replies.

shaunk

Programmer
Aug 20, 2001
402
0
0
AU
The database is Access 2000.
I am attempting to assign the recordset returned from the Getrows method directly to an array as per the following code.

Code:
Dim arrPassword()
    
strSql = "Select count(*),Keycode FROM tblPassword Group by Keycode"
    
arrPassword = CurrentProject.Connection.Execute(strSql, intRecordCount, adCmdText).GetRows
    
ReDim Preserve arrPassword(UBound(arrPassword, 1), UBound(arrPassword, 2))

...then process based on output

This avoids having to explicitly declare a recordset object and clean it up etc.
This works successfully if there are records returned,however, if there are no records to be returned, it fails with "Either BOF or EOF is true or the current record has been deleted".
It fails on the Execute command without giving giving the opportunity to test the contents of the array.

Is there a way to do this, or do I have t go through the whole recordset declaration etc.
Thanks

The risk with keeping an open mind is having your brains fall out.
Shaunk

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top