View Single Post
  #7  
Old July 12th, 2004, 02:43 AM
Jeff Conrad
external usenet poster
 
Posts: n/a
Default Save Report With CreateReport Coding Issue

Hi Doug,

On the read-only part I believe I was confused by this part:

"Note For a Reference object, this property is read-only in all views."

I've been known to be confused once or twice before.
g

Well my testing seems to show this works pretty well by saving it with
whatever Access wants the first time and then renaming the report on a
second pass. No problems so far.

It's actually quite coincidental (and humorous) that you chose to help me on
the last part of this project!
vvvvvvvvvbg

The project is now finished and it is a special gift for YOU!!!
Yep, you heard me.

It is the "Doug Steele Object Documentor" Access Add-In.
Version 1.0

I created an Access Add-In that will generate a nice slick report of all
objects in a database. It is based on your article this month in "Smart
Access" by Pinnacle Publishing. This particular article (if you remember) is
the one that you talked about having a nice report that could list all the
objects in a database. It is much simpler to use than the Documentor that
ships with Access if all you want is just a listing of the database objects.
You based the article on my idea and report and mentioned me in the article.
I am EXTREMELY grateful for the kind gesture and as a thank you I created an
Add-In based on the rptCatalog in your sample. And yes, the Add-In will
create the report YOU made, which is MUCH better than the one I made! g

I will send it along to you momentarily. The 97 version works with Access 97
and the 2000 version works with Access 2000, 2002, and 2003. I've tested it
extensively on all four of those versions and everything seems just fine.
Let me know if you have problems.

When you receive it, just unzip the file and place the Add-In (probably the
2000 one) in the Office directory (or somewhere easy to find). Use the
Add-In Manager to install the file. You may have to browse for the location.
Then just launch the Add-In from the list of installed Add-Ins and watch the
magic begin!! Poof!! Your slick report from the article is completely
generated all in code and then displayed on the screen for you! Sweeeeet!
The report is exactly like your sample down to every little detail.

The Add-In will save the report in the database as rptObjectDocumentor. You
can then just open the report any time you wish. Every time you run the
Add-In it will first check for the existence of this report in your database
using a function I made called IfExists. If the report exists in your
database it will just open the report. If the report is not present in the
database it will create one completely from code, save it, and then open it
for you.

Try it out and let me know what you think!
:-)
Feel free to try it on an MDE file, I've accounted for that as well.
I hope you like it and once again thanks for mentioning me in the article!

--
Jeff Conrad
Access Junkie
Bend, Oregon


"Douglas J. Steele" wrote in message
...
The Help file in Access 97 doesn't say anything about it being read-only,
although it does say

"For forms and reports, set the Name property by clicking Save on the File
menu in Design view and entering a valid name. To change the name of an
existing form or report in the Database window, click the name, then

either
click Rename on the Edit menu or click the name again. You can also change
the name by right-clicking it and clicking Rename on the shortcut menu. To
change the name of an existing form or report when the object is open,

click
Save As/Export on the File menu."

In other words, if you can't in fact set the name the way I suggested,

your
approach would seem to be valid.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)



"Jeff Conrad" wrote in message
...
Hi Doug!

Thanks for the assistance.
I thought it would be that easy as well, but that code produces error

2135.
Further checking of the Help files reveal that the Name property is Read
Only in all views.
Grrrr.....

I have a work-around by saving the report with the default name and then
renaming it.
It's a little weird, but it seems to work just fine in my tests.
What do you think?:

(strOldReportName is Dimmed as string)

' Remember the name of the report that Access has given it
strOldReportName = rpt.Name

' Close and save the report with the given name with no prompt for

user
DoCmd.Close acReport, rpt.Name, acSaveYes
' Refresh the database window to reflect the change
RefreshDatabaseWindow

' Now rename the report we just created to the name we want
DoCmd.Rename "rptNewName", acReport, strOldReportName
' Refresh the database window to reflect the change
RefreshDatabaseWindow

' All finished now so open the report in Preview mode
' Maximize the report and have it fill the whole screen
DoCmd.OpenReport "rptNewName", acViewPreview
DoCmd.Maximize
DoCmd.RunCommand acCmdFitToWindow

Do you think this is OK?
Seems to be just fine in testing.

--
Jeff Conrad
Access Junkie
Bend, Oregon


"Douglas J. Steele" wrote in message
...
Haven't bothered to test, but you should be able to do something like:

Set rpt = CreateReport
rpt.Name = "rptMyNameHere"

' put the rest of your code here

DoCmd.Close acReport, rpt.Name, acSaveYes

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)



"Jeff Conrad" wrote in message
...
Hi,

Using Access 97 at the moment.
After building a report in code using CreateReport and

CreateReportControl
coding I wish to save the report without being prompted for the

name.
Fine
enough I can do that by using code like this at the end:

DoCmd.Close acReport, rpt.Name, acSaveYes

But, how do I save the report with a name of my choosing without

being
prompted?
Right now it saves it as Report1 or Report2, etc.
I have already assigned a caption for the report so I assumed it

would
save
the report with that name. I was incorrect.
If I try something like this:

DoCmd.Close acReport, "rptMyNameHere", acSaveYes

Access says it can't find that report.
Is this not possible to do?

Do I have to save the report with the default name and then rename

it
in
code?

Thanks,
--
Jeff Conrad
Access Junkie
Bend, Oregon