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

Skipping a Table or Recordset

Status
Not open for further replies.

YellowTail

Programmer
Nov 9, 2006
2
US
I have to count the number records that are in a particlur recordset. I use an array to cycle through the different tables I need to read. Is there a way to skip over a table or recordset if the table or recordset contains no values at this time.

Dim controls(16)

controls(0) = "AC"
controls(1) = "AT"


For Each i In controls
Set db = CurrentDb()
Set rec = db.OpenRecordset("3_" & i & "_In_Place", dbOpenDynaset)
adOpenDynamic
rec.MoveLast
rs = rec.RecordCount

Next
 
How would you know it contains no records without opening it?

Greg
"Personally, I am always ready to learn, although I do not always like being taught." - Winston Churchill
 
Code:
'Only check count if there are records in the result set
If Not (rec.BOF And rec.EOF) Then
    rec.MoveLast
    rs = rec.RecordCount
End If



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top