Cannot Rename a Report (1 Viewer)

RodShinall

Registered User.
Local time
Today, 02:18
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.
 

JHB

Have been here a while
Local time
Today, 09:18
Joined
Jun 17, 2012
Messages
7,732
Have you saved your database/code?
 

RodShinall

Registered User.
Local time
Today, 02:18
Joined
Dec 21, 2006
Messages
32
Yes, I have closed the database, reopened it and get the same result. Thank you for replying.
 

pr2-eugin

Super Moderator
Local time
Today, 08:18
Joined
Nov 30, 2011
Messages
8,494
One question still remains "WHY?"

What is the need to rename an Object in Runtime?
 

JHB

Have been here a while
Local time
Today, 09:18
Joined
Jun 17, 2012
Messages
7,732
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"
 

RodShinall

Registered User.
Local time
Today, 02:18
Joined
Dec 21, 2006
Messages
32
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.
 

JHB

Have been here a while
Local time
Today, 09:18
Joined
Jun 17, 2012
Messages
7,732
Good you found the problem, luck with your project.
 

Users who are viewing this thread

Top Bottom