Renaming Reports For Emailing

A

Arturo

I previously posted this question.

I am using the SendObject method to email a report as a Snapshot. The name of
the report is rptBilling. It names the Snapshot the same thing. How do I
rename this? I would like to name it “Bill For (first and last name of person
in the report).†Is this possible? The respective field names are FirstName
and LastName.

I was presented the code below.

Private Sub Report_Activate()
Me.Caption = "Report for " & [FirstName] & " " & [LastName]

ExitProc:
Exit Sub
ProcError:
MsgBox "Error: " & err.Number & ". " & err.Description, _
vbCritical, "Error in Report_Activate event procedure..."
Resume ExitProc
End Sub

This works great if I go from design view to Print Preview. However, if I
just open the report by double clicking on it, or with the following code
from a procedure on a form:

DoCmd.OpenReport "rptBilling", acViewPreview

I get a Visual Basic error 2427 that says “You entered an expression that
has no value.â€

Any ideas on how to correct this?
 
A

a a r o n . k e m p f

SQL Server supports emailing reports automagically.

it's called 'subscriptions'.

Jet is stuck in the 90s and anyone using it for any reason should be
fired.

-Aaron
 
G

George

You do realize, don't you, that "automagically" is a made-up word, the use
of which reflects poorly on the person who pretends that some processes
occur "as if by magic"? We're all here trying to offer sound technical
advice, each to the best of our own abilities, skills and knowledge, so
telling people that SQL Server supports "magical" processes seems, well,
inappropriate, at best.



message
SQL Server supports emailing reports automagically.

it's called 'subscriptions'.

Jet is stuck in the 90s and anyone using it for any reason should be
fired.

-Aaron
 
G

GenlAccess

George said:
You do realize, don't you, that "automagically" is a made-up word, the use
of which reflects poorly on the person who pretends that some processes
occur "as if by magic"?

It would be a "magical" happening if anyone other than someone brand new to
the newsgroup took aaron to be a sane, serious, and sensible dispenser of
database development advice. He is obsessed with his pet subject (SQL
Server) and recommends it as the solution to all problems, from corns to
migraines, and everything in between.

Gen'l Access
 
A

Arturo

I know all this. I have to overcome the anti-Access group all the time.
They apparently don't know the answer to the question and try to cover
it up by accusing the Access users of ignorance. Their normal response
is "You can't do that." My comeback is "No. You can't do that." It takes
time on some of these occasions to get the problem fixed, but, eventually
we encounter someone that does know the correct answer. It is usually
someone that has an open mind and is creative in their thinking.

Is there any Access users that can solve my delimna with renaming the
reports? I would really appreciate it if you could.

Thank you.
 
T

Tom Wickerath

Hi Arturo,

I just tried this out, using an report generated in the sample Northwind
database, based on the Employees table. This table includes fields named
FirstName and LastName. The code works fine for me; I can open the report
directly from the database window, by double-clicking on it, and I see the
correct caption. I'm also able to open it via a command button on a form, and
the caption works as expected.

Try the following:
1.) Verify that your VBA code compiles without any errors. Open any code
module and click on Debug | Compile {ProjectName}.

2.) Do a Compact and repair operation.

3.) Reboot your PC.

4.) Try creating the sample in Northwind, as I did. Can you get it to work
there?



Tom Wickerath
Microsoft Access MVP
http://www.accessmvp.com/TWickerath/
http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________
 
A

Arturo

I put the code in the button on the form and it worked. Thanks for all your
help.

Tom Wickerath said:
Hi Arturo,

I just tried this out, using an report generated in the sample Northwind
database, based on the Employees table. This table includes fields named
FirstName and LastName. The code works fine for me; I can open the report
directly from the database window, by double-clicking on it, and I see the
correct caption. I'm also able to open it via a command button on a form, and
the caption works as expected.

Try the following:
1.) Verify that your VBA code compiles without any errors. Open any code
module and click on Debug | Compile {ProjectName}.

2.) Do a Compact and repair operation.

3.) Reboot your PC.

4.) Try creating the sample in Northwind, as I did. Can you get it to work
there?



Tom Wickerath
Microsoft Access MVP
http://www.accessmvp.com/TWickerath/
http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________


Arturo said:
I previously posted this question.

I am using the SendObject method to email a report as a Snapshot. The name of
the report is rptBilling. It names the Snapshot the same thing. How do I
rename this? I would like to name it “Bill For (first and last name of person
in the report).†Is this possible? The respective field names are FirstName
and LastName.

I was presented the code below.

Private Sub Report_Activate()
Me.Caption = "Report for " & [FirstName] & " " & [LastName]

ExitProc:
Exit Sub
ProcError:
MsgBox "Error: " & err.Number & ". " & err.Description, _
vbCritical, "Error in Report_Activate event procedure..."
Resume ExitProc
End Sub

This works great if I go from design view to Print Preview. However, if I
just open the report by double clicking on it, or with the following code
from a procedure on a form:

DoCmd.OpenReport "rptBilling", acViewPreview

I get a Visual Basic error 2427 that says “You entered an expression that
has no value.â€

Any ideas on how to correct this?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top