Solved

Edit a report from VBA

Posted on 2012-03-16
4
240 Views
Last Modified: 2012-03-16
Dear Experts

I need to edit a report from a piece of code residing in a form.

Basically I need to replace the reports's tag (which is a string formed from a collation of various data points in the form).This is so the label which acts as the header for the report is changed (it has a control source of =[Report].[Tag])

The report is called "Bespoke Contact Logs by User" and the string to go into [tag] is "StrReportHeader"

Can anybody help?
0
Comment
Question by:correlate
  • 2
  • 2
4 Comments
 
LVL 61

Accepted Solution

by:
mbizup earned 500 total points
Comment Utility
Can you use OpenArgs instead?

Docmd.OpenReport "YourReport", WhereCondition:= "Your Criteria", OpenArgs:=StrReportHeader


And in the openevent of the report:

YourLabel.Caption  = Me.OpenArgs
0
 

Author Comment

by:correlate
Comment Utility
I think so, what I'm planning on doing in VBA is to open the report, edit it, close it & dependant upon user selection this report would then either be emailed, put into Pdf or saved as a pdf ... I cant think of any reason why OpenArgs would work - what do you think?
0
 
LVL 61

Expert Comment

by:mbizup
Comment Utility
It sounds doable.

Another option - assuming the form is open at the time the Report's Open event is exectued, is to refer to the form for the value needed:

Me.MyLabel.Caption = Forms!YourFormName.YourControlThatHoldsTheHeaderText

(you can also place this in the control source of a textbox...)


OpenArgs is a little cleaner, IMO.
0
 

Author Closing Comment

by:correlate
Comment Utility
Works a treat - thank you very much
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now