A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Setting Up & Running Reports
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Save Report With CreateReport Coding Issue



 
 
Thread Tools Display Modes
  #1  
Old July 11th, 2004, 04:19 AM
Jeff Conrad
external usenet poster
 
Posts: n/a
Default Save Report With CreateReport Coding Issue

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


  #2  
Old July 11th, 2004, 12:07 PM
Douglas J. Steele
external usenet poster
 
Posts: n/a
Default Save Report With CreateReport Coding Issue

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




  #3  
Old July 11th, 2004, 08:44 PM
Jeff Conrad
external usenet poster
 
Posts: n/a
Default Save Report With CreateReport Coding Issue

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






  #4  
Old July 11th, 2004, 09:01 PM
Douglas J. Steele
external usenet poster
 
Posts: n/a
Default Save Report With CreateReport Coding Issue

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








  #5  
Old July 12th, 2004, 02:37 AM
david epsom dot com dot au
external usenet poster
 
Posts: n/a
Default Save Report With CreateReport Coding Issue

rpt.SaveAs "NewName"

docmd.close acreport, "NewName", acSaveNo

(david)

"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




  #6  
Old July 12th, 2004, 02:40 AM
david epsom dot com dot au
external usenet poster
 
Posts: n/a
Default Save Report With CreateReport Coding Issue


or
If s_Fixup_String(sRptName, sRptName) sRptName Then
DoCmd.Rename s_Fixup_String(sRptName), acReport, sRptName
End If

.... But I'm having trouble in A2000:

Problem: In A2K I sometimes get an error like 'cannot continue ...
stop the code and try again' at DoCmd.Save. I need to SAVE
the CODE PROJECT before it will save the report. Works OK in A97.

does anyone have any insight?


  #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










  #8  
Old July 12th, 2004, 03:12 AM
Jeff Conrad
external usenet poster
 
Posts: n/a
Default Save Report With CreateReport Coding Issue

Hi David,

Thanks for the extra help, I will try these ideas out as well.
Quick question: Is s_Fixup_String a built-in function in Access or is this a
custom made function?

Thanks,

--
Jeff Conrad
Access Junkie
Bend, Oregon


"david epsom dot com dot au" david@epsomdotcomdotau wrote in message
...

or
If s_Fixup_String(sRptName, sRptName) sRptName Then
DoCmd.Rename s_Fixup_String(sRptName), acReport, sRptName
End If

... But I'm having trouble in A2000:

Problem: In A2K I sometimes get an error like 'cannot continue ...
stop the code and try again' at DoCmd.Save. I need to SAVE
the CODE PROJECT before it will save the report. Works OK in A97.

does anyone have any insight?




  #9  
Old July 12th, 2004, 08:39 AM
david epsom dot com dot au
external usenet poster
 
Posts: n/a
Default Save Report With CreateReport Coding Issue

Quick question: Is s_Fixup_String a built-in function in Access.

Naaah. And it's the ugliest bit of code in the whole office.
I type the strings I want to modify into s_Fixup_String and do
modify & replace w/o even benefit of the A2K replace function.

(david)


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

Thanks for the extra help, I will try these ideas out as well.
Quick question: Is s_Fixup_String a built-in function in Access or is this

a
custom made function?

Thanks,

--
Jeff Conrad
Access Junkie
Bend, Oregon


"david epsom dot com dot au" david@epsomdotcomdotau wrote in message
...

or
If s_Fixup_String(sRptName, sRptName) sRptName Then
DoCmd.Rename s_Fixup_String(sRptName), acReport, sRptName
End If

... But I'm having trouble in A2000:

Problem: In A2K I sometimes get an error like 'cannot continue ...
stop the code and try again' at DoCmd.Save. I need to SAVE
the CODE PROJECT before it will save the report. Works OK in A97.

does anyone have any insight?






 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
6 Tables, 1 Report, W/O 6 Qrys Andy Setting Up & Running Reports 9 June 29th, 2004 09:52 PM
Label SRIT General Discussion 2 June 22nd, 2004 09:42 PM
Report copies issue EdS Setting Up & Running Reports 1 June 11th, 2004 08:54 PM
Can't save report if other user in db dw Setting Up & Running Reports 2 June 7th, 2004 06:40 PM
report calculation issue - previosu month sales Gabrielle Setting Up & Running Reports 0 May 25th, 2004 06:52 PM


All times are GMT +1. The time now is 03:47 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.