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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Master/Child field link complication for subreports!

Status
Not open for further replies.

NKA

Programmer
Mar 20, 2002
76
NZ
We are trying to link a subreport to the main report by doing the following.

Identify a character in a text string and link the subreport with everything to the right of that character.

Example.

Main report has field [location]. Value = V546

Subreport has field [job_account]. Value = 4 S > V546.

The "4" is variable (ie could be 4004)
(space) "S" (space) ">" (space) are static
The remaining characters are variable too.

The idea is to look for everything after the ">" (space).

Would anyone have an idea what code I should be using to get these to link. I am guessing that I need to create a new field in my subreport query, but don't know what to use!

Any help greatly appreciated.

Cheers

NKA

The answer's always easy - if you know it! ;-)
 
hi

in the sub report (or to be exact the query on which it is based, make a calculated column:

mynewcol:=MyFunc([job_account])

the user function MyFunc(), needs to be written by you to return the relevant data, do you know how to do that?

include mynewcol on the (sub)report with visible set false

set the master child fileds to location and mynewcol

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Thanks Ken.

No, I don't know how to do that!!! I knew I needed to create a new column to do the "checking" - but didn't know what to do with it!!

What's the MyFunc function you are referring to? I don't know how to do that!!

Cheers


NKA

The answer's always easy - if you know it! ;-)
 
Hi

In a code module

Option Compare Database
Option Explicit

Public Function MyFunc(s As String) As String
Dim i As Integer
i = InStr(1, s, "> ")
If i = 0 Then
MyFunc = s
Else
MyFunc = Mid(s, i + 2)
End If
End Function


this is a "user function" you can use it just like a regular Access Function, it will return the bit of the string after the "> "

eg

? MyFunc("4 S > V546")
V546

so using this with my first post should allow you to do what you are trying to do

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top