I just converted a 3-yr old Access 2003 database to 2010 for testing. I have a piece of VBA code I use often that checks temporary tables to make sure they were properly emptied after use and, if not, deletes all the records so they are ready for the next use.
In the 2003 version, the code looked like this and worked without any problems:
Dim db As Database
Dim table_RST As Recordset
Set db = CurrentDb
Set table_RST = db.OpenRecordset ("tbl_TempTable", dbOpenDynaset)
If (table_RST.RecordCount > 0) Then
Do While (Not table_RST.EOF)
In Access 2010, I now get a error that the "DoCmd.Delete" command is not vaild. So, I did a little looking around and tried replacing that line with the following two lines:
When I try to run this, I get a Run-time error 2046 saying that the "command or action 'DeleteRecord' isn't available now."
All my forms are unbound and I use VB Scripting almost exclusively to move data from tables to forms, so I don't think it is a record lock problem. But, I don't know how to correct it. Any suggestions? Thanks!