aziz rasul
Active member
- Local time
- Today, 13:07
- Joined
- Jun 26, 2000
- Messages
- 1,935
I have written code which goes thru each table and does a count and places the values into a table. I use MoveLast & RecordCount to obtain the answers.
If I come across a table that contains no records I get a 3021 error. How can I check whether a table has any records before doing the RecordCount? I have been trying to use AbsolutePosition but can't get it to work. Here's the code so far.
With dbs
For Each tdf In .TableDefs
strTableName = tdf.Name
Set rst = .OpenRecordset(strTableName)
lngX = rst.AbsolutePosition + 1
rst.MoveLast
lngCount = rst.RecordCount
With rstCount
.AddNew
!TableName = strTableName
!RecordCount = lngCount
!DateofCount = Now()
.Update
End With
rst.Close
Next
End With
I get a run-time error on the lngX line i.e. 3251 (Operation is not supported for this type of object)
If I come across a table that contains no records I get a 3021 error. How can I check whether a table has any records before doing the RecordCount? I have been trying to use AbsolutePosition but can't get it to work. Here's the code so far.
With dbs
For Each tdf In .TableDefs
strTableName = tdf.Name
Set rst = .OpenRecordset(strTableName)
lngX = rst.AbsolutePosition + 1
rst.MoveLast
lngCount = rst.RecordCount
With rstCount
.AddNew
!TableName = strTableName
!RecordCount = lngCount
!DateofCount = Now()
.Update
End With
rst.Close
Next
End With
I get a run-time error on the lngX line i.e. 3251 (Operation is not supported for this type of object)