473,385 Members | 1,736 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,385 software developers and data experts.

using of "parent" in a report in order to omit superflous reports

I have 2 forms. In each of them I call a different report.
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenReport "481rpt_KursteilnehmerQuittungDrucken", _
  2.    acPreview
  3. DoCmd.OpenReport "483rpt_TermineQuittungDrucken", _
  4.     acPreview
  5.  
Inside the reports the datasource is referenced with
Expand|Select|Wrap|Line Numbers
  1.    =[Formulare]![481frm_KursTeilnehmerErfassen]![KLNachname]
  2. or
  3.    =[Formulare]![483frm_TerminsErfassen]![KLNachname]
  4.  
  5.  
Don't get troubled: Formulare is German and means forms!!

As you easily see, they are very similar. I tried to use the same fieldnames in both of the forms.
I have the strong feeling, that ONE report could be omitted.
So I looked for a reference like
Expand|Select|Wrap|Line Numbers
  1.     =[Formulare]!me.form![KLNachname]
  2. or
  3.     =[Formulare]!parent.form![KLNachname]
It is a shame - I was not successful. Can you help me?
Thank you all
May 11 '15 #1
11 1112
zmbd
5,501 Expert Mod 4TB
You've only provided names of reports and examples of functions; however, you've really provided no information about the reports/forms themselves nor the structure pertaining to the scope of the calling code.

TBH: The inclusion or omission of a report is really something that is decided by your client and not something that many of use would be able to help you decide. A specific question about how to include/exclude something, formatting, even occasionally a suggestion on how to design a project (especially when it comes to normalization ) that we can be of more help with...
May 11 '15 #2
zmbd, thank you. I should add: it is ACCESS 2013

I tried to be short as it was recommended. There is no VBA-Code. Just a reference in a field in the report to a field in a forms which must be opened (otherwise the reference will not work).

The reference for the field
Expand|Select|Wrap|Line Numbers
  1. =[Formulare]![481frm_KursTeilnehmerErfassen]![KLNachname]
is given as datasource (German: Steuerelementinhalt).

The name of the form "481frm_K...." is static. If I use a dynamic term to reference a form in a field of a report (e.g. "me" or "parent") I hope to be more elegant.

The simple?? question is: how looks an example of a reference inside a field of a report to a field of a form using me or parent?

[I was sure that in this community we all talk about access therefore I did not give this information]
May 11 '15 #3
jforbes
1,107 Expert 1GB
There are a few ways to do what you are attempting. For you, I would look into TempVars first, then possibly OpenArgs.

Here is a thread that is similar in nature: http://bytes.com/topic/access/answer...cked-main-form
Syntax of using a TempVar as the Source for a Report Control: http://bytes.com/topic/access/answer...command-button
May 11 '15 #4
Thank you, jforbes

openargs was my first idea. As far as I understood, with openargs I can pass only ONE argument from the form to the report. Actually there are 8 variables to pass.

But you gave me the following idea: If it is not possible to give more than ONE argument, than I will gather the 8 variables into ONE argument, in which these 8 variables are separated by e.g. @. Then I will divide this ONE argument inside the report into 8 variables. I will do this with VBA-Code. This is not as elegant as my introducing question concerning "parent", but ...

Again: Thank you
May 11 '15 #5
zmbd
5,501 Expert Mod 4TB
BeckerHarald, from the information you've given, I'd point you in the same direction as jforbes.

As for this being an Access forum, you are correct, and we do appreciate you being brief and to the point; however, Access is a very fluid development environment and when one posts just snippets of code/script one must provide proper context.

For example in your original post:
... Inside the reports the datasource is referenced with ...
isn't clear in that the report can have a record source and the control can have a control source, which one might lump together and call "datasource" even if not technically correct, and the explanation you have provided, along with your title, leads one to wonder if you are using a parent/subreport format and just exactly how is it that the form is related to the report that would possibly allow Me/Parent scope between the report and the form?

AND NOW

You have provided us with even more information regarding the multiple parameters you wish to pass to the report.

I have a link for that and will update this post in a minute once I find and verify it still works:
<<update>>I see that you have the same idea as the link, personally, I use the split function and the pipe character ( | ) as the "@" can occasionally give you problems. You might want to look at the underlying query to see if a parameters based approach would work.

Also, you clearly state that there is no VBA code and yet, DoCmd.OpenReport is a VBA function so there is VBA code being used in your project.
May 11 '15 #6
jforbes
1,107 Expert 1GB
There is one more thing that you could consider. Sending the Form Name as the OpenArgs. I use this technique for Forms, but it would work with Reports quite well.

I mocked this up from some code I had and with what you provided. It is still Form based, so you'll have to shoehorn it into a Report, if you want.
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2.     ' Put the Parent in a hidden field
  3.     Me.ParentForm.Value = Nz(Me.OpenArgs, "")
  4. End Sub
  5. Private Sub cmdOK_Click()
  6.     Dim sParent As String
  7.     sParent = Nz(Me.ParentForm.Value, "")
  8.     If isLoaded(sParent) Then
  9.         Select Case sParent
  10.             Case "481frm_KursTeilnehmerErfassen"
  11.                 Me.KLNachname=[Formulare]![481frm_KursTeilnehmerErfassen]![KLNachname]
  12.             Case "483frm_TerminsErfassen"
  13.                 Me.KLNachname=[Formulare]![483frm_TerminsErfassen]![KLNachname]
  14.         End Select
  15.     End If
  16. End Sub
  17. Function isLoaded(ByRef sFormName As String) As Boolean
  18.     ' Determines if a Form is loaded
  19.     Dim i As Integer
  20.  
  21.     isLoaded = False
  22.     For i = 0 To Forms.Count - 1
  23.         If Forms(i).FormName = sFormName Then
  24.             isLoaded = True
  25.             Exit Function
  26.         End If
  27.     Next
  28. End Function
  29.  
Also, there are a few other ways to refer to an open form and the syntax like the following may simply things for you:
Expand|Select|Wrap|Line Numbers
  1. Forms("481frm_KursTeilnehmerErfassen")![KLNachname]
May 11 '15 #7
zmbd
5,501 Expert Mod 4TB
J, that's pretty slick, sending the form name in the openargs, I wouldn't have thought to do that, I normally put a parameter query together using a form to fetch user input.

I wonder if there isn't something that we're missing here as to the overall database design that could make the project easier for OP.
May 11 '15 #8
To zmbd and jforbes!

zmbd, now after you showed me, what you mean when you ask me to give more information I am a little angry - with me!
I am/was too deep involved into my problem that a structured thinking was impossible.

jforbes, although I got no answer if there is a valid syntax (or example) for a reference from the control source?? of a report field to a field in a form, my problem is solved!

I tried to omit superflous reports while using "me or parent". Now I am able to omit these reports. Instead I will have only ONE report left for this given situation while using openargs.

Thank you ALL. I really appriciate the fast way you tried to help.

And good night - it is bed time in Germany!
May 11 '15 #9
zmbd
5,501 Expert Mod 4TB
I am/was too deep involved into my problem that a structured thinking was impossible.
If I had a dollar/EUR/DEM for every tree I've ran into because of the forest I'd fly over and we go for a beer.

:-)
May 11 '15 #10
jforbes
1,107 Expert 1GB
Glad to hear that you got things working for you.

I took it as a challenge to find a way to define a Control Source that would pull the value from a "Parent" Form and here is what I came up with.

For the Form calling the Report, pass the Form Name as an OpenArg:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command0_Click()
  2.     DoCmd.OpenReport "rptReportWithOpenArgs", acViewPreview, , , , Me.Name
  3. End Sub
  4.  
Then in the Report on Load Event put the OpenArg in a Report Variable. This will make the Calling Form Name available for a Function that would retrieve the value from the calling Form. Code from the Report
Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3. Private nFormName
  4. Private Sub Report_Load()
  5.     nFormName = Nz(Me.OpenArgs, "")
  6. End Sub
  7. Private Function getParentValue(ByRef sValue As String) As String
  8. On Error GoTo ErrorOut
  9.     If Len(nFormName) > 0 Then getParentValue = Forms(nFormName).Controls(sValue)
  10. ExitOut:
  11.     Exit Function
  12. ErrorOut:
  13.     MsgBox ("Error in rptReportWiothOpenArgs.getParentValue. Form Name of '" & nFormName & "' Value of '" & sValue & "' " & vbCrLf & vbCrLf & Err.Description)
  14.     Resume ExitOut
  15. End Function
  16.  
Then on the Report if a Controls Source is set like this:
Expand|Select|Wrap|Line Numbers
  1. =getParentValue("txtReportTitle")
the value that is shown on the report will be the Value of the Control named "txtReportTitle" on the "Parent" Form.

I think there is more that could be done, but I need to get back to work. =)
May 12 '15 #11
Hi jforbes,
after you mentioned to pass the name of the form into the report I immediately forgot to sample the 8 variables in the form, pass them as ONE openargs and split them in the report.
Both, my (old) solution and your (new) solution above need VBA but yours only as load-event. Means, yours is more elegant, means subsequently I will use it as shown by you.

And by this way I learned the possibility to use a function in the Controls Source! You made my day! Thank you!
May 12 '15 #12

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

Similar topics

4
by: Mike | last post by:
Hello All, I'm trying to deploy my windows-based application using crystal report. i package the setup by including the crystal report file, the exe file, and two merge modules for the crystal...
3
by: jimfortune | last post by:
At what point is a Form added to the Forms collection or a Report added to the Report collection? I.e., listed as currently open. The reason I ask is that I have a subreport for an exclusive...
1
by: monskie | last post by:
Hello to all, I have a problem which could be trivial to you guys. This concerns opening several crystal reports on the a crystal viewer on an ASPX page by calling window.open. My...
0
by: Rabbit | last post by:
recently I monitor my web application using Crystal report for .net, I notice everytime I call CrystalReportView control to display the report, the memory usage go up by 2MB, upto certain level,...
10
by: john | last post by:
I have a report to print envelopes. The report is based on a query. Now I need to make 10 more queries to make different selections of addresses. Every query has the same output fields as the...
2
pureenhanoi
by: pureenhanoi | last post by:
i'm using VB6 to create application. My application connect to database (MS-SQL Server) through ODBC. i'm using Crystal Report too. But there is a problem here: if my SQL Server does not need...
1
by: gzali | last post by:
hi, i want to send parameter on web by using crystal report,the problem is that i am using crystal report 8.5 i am using a heperlink on a report filed, when the user click on the heperlink the...
0
by: Jason7899 | last post by:
hi I’m creating a small program to draw up an estimate and after that I want it to be printed using the crystal report 7, and I wonder if someone has a similar sample program. I also thought of...
3
by: justme43 | last post by:
I have report with 2 sub reports. the sub reports provide balances for the main report. this is sub 1 provides balance to end of last month. sub 2 provides balance for current month. In the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.