Cannot Rename a Report

RodShinall

Registered User.
Local time
Today, 17:36
Joined
Dec 21, 2006
Messages
32
I want to rename a report by clicking a command button on a form. I have this simple code in the click event:

Dim strReportNameNew As String
Dim strReportNameOld As String
strReportNameNew = txtChangeTo.Text
strReportNameOld = txtChooseReport.Text
DoCmd.Rename strReportNameNew, acReport, strReportNameOld

The code fails with this error message:
Microsoft Visual Basic
Run-time error '29068'
Household Labels cannot complete this operation. You must stop the code and try again.

I am able to rename the report manually.
I have searched but been unable to find out what is causing this error. Any help would be greatly appreciated.
 
Have you saved your database/code?
 
Yes, I have closed the database, reopened it and get the same result. Thank you for replying.
 
One question still remains "WHY?"

What is the need to rename an Object in Runtime?
 
Yes, I have closed the database, reopened it and get the same result. Thank you for replying.
Create a new form, put a button in it and the code in on Click event, (only to see if you are able to do it with hard code report name).


Code:
  DoCmd.Rename "AReportNameYouHaveInTheDatabase", acReport, "AReportName1"
 
Sorry for the delay in replying. I had to be away for several hours.
I did just as you advised and did not get the error so I figured it must be syntax issue. I took a really close look at my variables and their assigned values and I found the problem. The code now works as I intended. I also added code to open, save, and then close the renamed report immediately after renaming it. Thank you for putting me on the right path.
 
Good you found the problem, luck with your project.
 

Users who are viewing this thread

Back
Top Bottom