473,324 Members | 2,257 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,324 software developers and data experts.

report question

266 256MB
i have a form that filters results based on an entry in an unbound text box, i then have a button that creates a report from those filtered results, using this code

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command8_Click()
  2.   If Me.Filter = "" Then
  3.         MsgBox "Apply a filter to the form first."
  4.     Else
  5.         DoCmd.OpenReport "Id", acViewPreview, , Me.Filter
  6.     End If
is there a way to put a heading on the report by entering it into an unbound text box in the form. so if im making an attendance report, i would like to enter 'attendance' in an unbound text box after i do my filter and then create my report and 'attendance' would be on the top of the report... thanks!
Jan 12 '10 #1
7 1451
nico5038
3,080 Expert 2GB
For this I use a "Header/Footer" table with the name of the report as (part of) the key.
Thus each report can have a different header/footer and by storing it the user can always see the last entered value. (easy when multiple reports with same header should be produced.)

Idea ?

Nic;o)
Jan 12 '10 #2
TheSmileyCoder
2,322 Expert Mod 2GB
Add a label to your report in the report Header section, and name it lbl_ReportTitle. Format it as you would like to see the report title, and make sure its wide enough to contain what people might write as a report title.
If your report header section is not visible, you can add it by clicking on the detail section, and then selecting Report Header/Footer.

Now add the following code to the Reports open event

Expand|Select|Wrap|Line Numbers
  1. Private Sub Report_Open(Cancel as Integer)
  2.   me.lbl_ReportTitle=OpenArgs & ""
  3. End Sub
The "" after the OpenArgs assures that if OpenArgs is null the code wont fail.

Add a textbox to your form, name it tb_ReportTitle.
Modify the code line of the command button to:
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenReport "Id", acViewPreview, , Me.Filter ,, Me.tb_ReportTitle & ""
Another way of doing it without the textbox is to use a inputbox:
Expand|Select|Wrap|Line Numbers
  1. Dim strOpenArgs As String
  2. strOpenArgs=InputBox("Name Report:","Report Title","Report Title")
  3. DoCmd.OpenReport "Id", acViewPreview, , Me.Filter ,, strOpenArgs
Hope it helps.
Jan 12 '10 #3
didacticone
266 256MB
i actually came up with this earlier...

Expand|Select|Wrap|Line Numbers
  1. Me.rpttxt = Forms!FormName!FormField
it works well... any thoughts id be glad to hear... thanks for your answers though!
Jan 12 '10 #4
nico5038
3,080 Expert 2GB
I prefer not to refer to forms as a change of the form name or starting a report from a different form will cause "trouble".
The mentioned "OpenArgs" is preferable for "ad-hoc" passing of data and can be used "universally" as the table solution is "heavier" and would offer the user the advantage to have his(her) own text for a header or footer per report, thus saving you the trouble to add default texts like copyright, address info, etc..

Nic;o)
Jan 12 '10 #5
didacticone
266 256MB
when i try it the way suggested, i get an error. "you cannot assign a value to this object" with the following highlighted

me.lbl_ReportTitle=OpenArgs & ""
Jan 13 '10 #6
TheSmileyCoder
2,322 Expert Mod 2GB
My bad. Labels have a Caption not a value, so you need to include the .Caption to assign to labels.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Report_Open(Cancel as Integer) 
  2.   me.lbl_ReportTitle.Caption=OpenArgs & "" 
  3. End Sub
Jan 13 '10 #7
didacticone
266 256MB
yep there it goes... awesome! thanks for your help!
Jan 13 '10 #8

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

Similar topics

1
by: Stephan | last post by:
Hi, I'm using Visual Studio 2003 (C#) with the integrated Crystal Report software and have the following question: How can I assign a value (string) to an unbound (string) field in Crystal...
0
by: Danny J. Lesandrini | last post by:
First, this is _not_ a question about how to get Crystal Reports to run on a client machine. I've got all the merge modules added to the project and it's working fine. The question is about...
3
by: CSDunn | last post by:
Hello, I have a situation with MS Access 2000 in which I need to display report data in spreadsheet orientation (much like a datasheet view for a form). If you think of the report in terms of what...
2
by: Tom | last post by:
This is related to an earlier post entitled "Text in Query/Numbers in Report" Brief recap - report has a query as a record source. The query shows the correct data, the report translating the...
0
by: Danny J. Lesandrini | last post by:
Didn't get any takers on this post this morning at dotnet.General, so I'm reposting here. First, this is _not_ a question about how to get Crystal Reports to run on a client machine. I've got...
0
by: Kaur | last post by:
Hi, I am trying to create a crosstab type of report without using crosstab query. The report captures several survey questions and for each survey questions there are multiple choices that...
1
by: Stinky Pete | last post by:
Evening, I have a form that uses 5 pages (it's an electronic copy of the paper version) we are going to use for manufacturing non conformances and product deviations. In case your wondering,...
9
by: itmags | last post by:
I need to create a couple of reports, invoices, credit reports, etc... My question is: How/what is the best way to go about this using VB2005 / SQL Server 2000 Crystal Reports? MS Reporting?...
4
by: lorirobn | last post by:
Hi, I have a report displaying items that are missing from a room. I created 2 queries, the first getting the items IN the room, and the second being an "unmatched" query that references the...
35
by: JessicaZ | last post by:
Hi everyone! I'm new here and have a question regarding Leban's report to pdf tool. I am working on a database where we are using this code to send a report out to pdf(duh) BUT what I need to do is...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.