Solved

Edit a report from VBA

Posted on 2012-03-16
4
247 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 61

Accepted Solution

by:
mbizup earned 500 total points
ID: 37729174
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
ID: 37729220
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
ID: 37729238
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
ID: 37729542
Works a treat - thank you very much
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Delete table fields 3 48
Access 2010 Form - Turn Updating On - Off 31 98
PowerPivot (or MS Access ) -- Opening & Closing Balance 21 59
View SQL Count Records 3 32
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

739 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