473,325 Members | 2,308 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

set titlle of report based on button clicked on in the main form

9
I have one report with several buttons to open the report based on filters on the buttons. when button "A" is pressed, I want title of report to be "A"
when button "B" is clicked, title should be "B"
thanks
Jan 5 '15 #1

✓ answered by twinnyfo

Seth,

Good solution. I always forget about that option--which has been around forever--because I haven't had a need to use it.

Clearly the easier solution in this situation. Thanks!

10 1434
twinnyfo
3,653 Expert Mod 2GB
Expand|Select|Wrap|Line Numbers
  1. Reports![ReportName].Caption
will change the name of the report in its window, but I think you may be talking about a Title that prints on your Report?

If this is the case, the easiest way I can think of is to have the Title generated when you set the filters.

After the report is opened, use VBA to change either a Text Box or Label based on the Filters. E.g., button A is clicked,

Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenReport "ReportName", , , "WHERE Conditions"
  2. Reports![ReportName].txtTitle = "This is Report A"
I think that should help. Let us know if you run across other snags.
Jan 5 '15 #2
dovidg
9
thank you for your responce
this is my code
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenReport "RptUnion", acViewPreview, , "Check=-1"
  2. Reports![RptUnion].Title5 = "This is Report A"
title5 is an unbound textbox
there is no error message in the code but the text box is empty

thank you
dovid
Jan 5 '15 #3
twinnyfo
3,653 Expert Mod 2GB
That was unexpected--although I had not tried that before. based on how Access uses all other Objects, one could only assume the same would work for reports......

Is there a way you could establish a Global Variable using TempVars()? This could hold a value, then the Control Source for that Text box could be the value of the Variable.

Your Code to open the report would be:

Expand|Select|Wrap|Line Numbers
  1. Dim strReportName As String
  2. strReportName = "This is Report A"
  3. TempVars.Add "ReportName", strReportName
  4. DoCmd.OpenReport "RptUnion", acViewPreview
Then, the Control Source for the Text box is:

Expand|Select|Wrap|Line Numbers
  1. = TempVars("ReportName")
Hope this hepps!
Jan 5 '15 #4
Seth Schrock
2,965 Expert 2GB
Instead of using a Tempvar, I would just add an OpenArgs to the DoCmd.OpenReport command and then use the report's OnLoad event to set the value of Title5 to the value in the OpenArgs property.

Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenReport "RptUnion", acViewPreview, , "Check = -1", , "This is Report A"
Then in the report's OnLoad event,
Expand|Select|Wrap|Line Numbers
  1. Me.Title5 = Me.OpenArgs
Jan 5 '15 #5
twinnyfo
3,653 Expert Mod 2GB
Seth,

Good solution. I always forget about that option--which has been around forever--because I haven't had a need to use it.

Clearly the easier solution in this situation. Thanks!
Jan 5 '15 #6
dovidg
9
perfect, thanks for everything
dovid
Jan 5 '15 #7
twinnyfo
3,653 Expert Mod 2GB
I would suggest selecting Post #5 as the answer for this thread....
Jan 6 '15 #8
twinnyfo
3,653 Expert Mod 2GB
Your call to open the report would be:

Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenReport "RptUnion", acViewPreview, , "Check = -1", , 1 'or 2 or 3
The title is set in the OnOpen event as well.
Jan 8 '15 #9
zmbd
5,501 Expert Mod 4TB
<Split second question into its own thread>
Handle Multiple Reporting Options
Jan 8 '15 #10
dovidg
9
took me a bit to get it to work but it's perfect
learned a lot of new options
thanks for everything
dovid
Jan 8 '15 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Patrick | last post by:
i have the following .aspx file defined: ..... other tags here ... <asp:TableCell><asp:button id="AddButton" Runat="server" Text="Add New Vessel..."</asp:button></asp:TableCell> ..... other tags...
1
by: fleece | last post by:
I have a continuous form based on some selected criteria. Now I want to send the search results to a report. How could I do that? It's better if I could sort the results before export to report. ...
5
by: favor08 | last post by:
have a mainform called PendingsMain and a subform called PendingsSub. You can filter the subform by different filters and this works fine. i want to create a report that will print out the...
3
by: Apple001 | last post by:
I am having hard time finding the way to make the database below. I have: -Form "frmInvoice" with subform "Allocation" based on table "tblInvoice" and "tblAllocation". "invID" is auto number in...
1
by: rkm2 | last post by:
I currently have a form "UserSearchForm" which allows a user to select values from several different unbound combo boxes in the header section and press a search command which filters the list in the...
2
by: darnnnel | last post by:
Hi everyone! I’m not sure how to even begin. I have a form and a subform and they are not linked. I would like to have a button on the form that would only change the data in the subform,...
1
by: QCLee | last post by:
Hello Sir, Im here again asking for help. I have a form and a subform relate to HVAC Windward Table. i have a SAVE button on the form that when clicked it saves data on the HVAC Windward Table but...
16
by: Steve | last post by:
I am working on a database that has a main menu, many sub-menus and some sub-sub-menus. They are all forms that have numerous command buttons on them to open forms and reports in the database. The...
2
by: John Lewis | last post by:
I have created a windows form application using an Access 2003 db. I used the drag and drop methods to place the fields on the forms and the same with the second form using the related table from the...
4
beacon
by: beacon | last post by:
Hi everybody, I have a main form, frmDeficiency, that has a tab control, deficiencyTabControl, that has a subform, fsubEpisodeDetail, on page 2 of the tab control. I also have a command button...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.