Question : Cannot rename reports in Access 2007 runtime - bug?

The renaming of any object (report, query, table, etc.) fails without raising error in runtime Access 2007 environment.

The following command is simply ignored in the runtime environment of Access 2007 (by either using the /runtime switch or renaming the extension from .accdb to accdr).  Using SP1, Vista (but also tried on XP with all SPs updated).  I then thought that I should try this in a "true" runtime environment so I downloaded the real Access runtime (on a machine with no Access installed).  Still, same problem.

This does not work in runtime (no error is raised):
            DoCmd.Rename strNewName, acReport, strOldName

There is a work-around of this "bug" but it only works for renaming tables:
            CurrentDb.TableDefs("tblMyTable").Name = " tblMyTable2"
            CurrentDb.TableDefs.Refresh

That solves table renaming however this does not work for renaming reports.
I tried:
            CurrentDb.Containers("Reports").Documents(strOldName).Name = strNewName
            CurrentDb.Containers("Reports").Documents.Refresh

But this fails because the "Name" property is "read-only" using this method.

An ugly work-around would be to copy the report object, then delete the original, but this only contributes to the database "bloat" and IMO not practical.
            DoCmd.CopyObject , strNewName, acReport, strOldName
            DoCmd.DeleteObject acReport, strOldName

So, it appears that renaming of reports is impossible at this time in the runtime environment.  Any ideas for work-arounds?

Answer : Cannot rename reports in Access 2007 runtime - bug?

After much research, I have come to the conclusion that this is an undocumented bug in Access 2007.  The only work-around that I'm aware of is to copy the report object, then delete the original:

            DoCmd.CopyObject , strNewName, acReport, strOldName
            DoCmd.DeleteObject acReport, strOldName
Random Solutions  
 
programming4us programming4us