Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

passing values to or from a sub report 1

Status
Not open for further replies.

TruthInSatire

Programmer
Aug 12, 2002
2,964
US
Good morning.
We are trying to create a table of contents as found in this link:
We've got it working except some of the information we want to add to the ToC is in a sub report. We can add items 1,2,3 to the table of contents, but we also need to add table 1(a) from the sub report. what is the easiest way to accomplish this?


The report is laid out like this

Code:
--Detail------------------
item1  item2  item3
==sub report==============
item1(a)  item4  item5
==========================
--------------------------


Thanks in advance.


We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true.
 
have a look at the link child field and link parent field properties...

--------------------
Procrastinate Now!
 
I'm sorry, i'm not very proficient with access, can you elaborate?

We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true.
 
It is possible to add the update function to the subreport, for example, you could set the Format event for the (sub) report header to:

[tt]=UpdateToc([line_items],[parent])[/tt]

Parent will return a reference to the parent report.
 
Ok,I have
=UpdateToc([item1(a)],[item4],[Parent])

That works fine.

as soon as i add one of the parent elements to it i get a type mismatch.
=UpdateToc([item1(a)],[item4],[item1],[Parent])

Code:
Function UpdateToc(item1(a) As String, item4 As String, item1 As String, Rpt As Report)
TocTable.AddNew
        TocTable!i1a = item1(a)
        TocTable!i4 = item4
        TocTable!i1= item1
        TocTable![pageNumber] = 1
        TocTable.Update
any ideas
 
If you wish to refer to an item on the parent form, prefix it with [parent]:

=UpdateToc([item1(a)],[item4],[parent].[item1],[Parent])
 
Remou,
Thanks for the help so far. I've tried that and I still get the same type mismatch error. I've found if i remove the "as string" from the function declaration I do not get the error but nothing is inserted into the table.

I have checked the tables to ensure that everything is type text. If i can just get 2 more parent values added I'll be done with this project, thanks again for your help so far.

I'm tired of playing in code, here is my actual code.

in the onPrint event of the sub report
Code:
=UpdateToc([WUC],[partnum],[parent].[nomen],[parent].[type_desg],[parent].[Enter previous page# or "0"],[Parent])

the UpdateToc function
Code:
Function UpdateToc(TocEntry As String, ptno As String, nomenc, type_d, custPage As Integer, Rpt As Report)
        TocTable.AddNew
        TocTable!WUC = TocEntry
        TocTable!partno = ptno
        TocTable!NOMEN = nomenc
        TocTable!typedes = type_d
        TocTable![pageNumber] = Rpt.Page + custPage
        TocTable.Update
End Function

the [parent].[Enter previous page# or "0"] works beautifully. we couldn't get that to work in the past.
 
Have you tried On Format, rather than On Print? Are you referring to an object such as a subform control in one of those references?
 
for some reason it isn't saving anything to the table onFormat.
I just noticed that the nomen and type_desg are not in the detail area, they are in the "wra_nbr header" section. does that make a difference?

here is a view of the parent report.
 
It shouldn't, however I did all my testing using Format events. Does it save using the print event? Have you tried stepping through the code to check the values being passed to the update module?
 
yeah, onPrint it works fine (except for the 2 values that give me a type mismatch error)
 
the onformat didn't seem to run i didn't get any errors and no values so it didn't seem to trigger at all. to be honest i'm not overly worried about that part at the moment.... getting the values into the table is much more pressing.
 
Have you tried stepping through the code to check the values being passed to the update module?
 
in order for me to do that i had to remove the "as string" for both items.

I added
'known to be a problem
MsgBox (":" + type_d + ":")
'known to be ok
MsgBox (":" + ptno + ":")

to the top of the function.

at first i got an "invalid use for NULL" on the type_d line.
after i commented it out i got a msg box with the part numbers in it one by one.

 
Ok, then type_d would appear to be null. Is it possible that you have mistaken the name of the control?
 
that appears to be the case. it was named field99 and nomen was field100.

when i tried to print the report after changing the names i started getting errors. changed them back and referred to them as 100 and 99 all is well. thank you much for your time.
 
In Access, it is often wise to rename controls on forms and reports, for example, a textbox that references nomen might be called txtNomen; similarly, a combobox could be called cboNomen, and so on.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top