Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Edit a report from VBA

Posted on 2012-03-16
4
Medium Priority
?
253 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 2000 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

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

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

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
If you’re using QODBC to update QuickBooks data from Microsoft® Access but Access is not showing the updated data, you could have set up QODBC incorrectly.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

971 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