T
tsawner
Been trying to work my way around this but just can't seem to get it
done.
It involves 1 Master Field and 2 Child Fields (which access can't seem
to deal with) so Im trying to go through VBA.
Simplified version of what im dealing with and my problem. There are
more parts to it, but I don't have any issues with those.
Report with 1 subreport. Main Report lists people by name. Subreport
Lists the responsiblities of the person in the main report. The tricky
part is that often 2 people are responsible for the same issue, the
subreport has two slots (person1, person2) to account for this. The
person listed in the main report could be in either slot. I need both
people on the list, rather than 2 records, because they are supposed to
work together to solve the issue.
Report Layout
--------------------------------------------------------------------------------
Person A
Issue-ID Person1 Person2 Issue 1
--------------------------------------------------------------------------------
Basically, I want it to come out like this.
--------------------------------------------------------------------------------
John Doe
1 John Doe Do XYZ
2 John Doe Tom Smith Do XYZ
3 Tom Smith John Doe Do XYZ
Tom Smith
2 John Doe Tom Smith Do XYZ
3 Tom Smith John Doe Do XYZ
4 Tom Smith Do XYZ
----------------------------------------------------------------------------------
What Im Winding Up With... (All records end up showing on both)
--------------------------------------------------------------------------------
John Doe
1 John Doe Do XYZ
2 John Doe Tom Smith Do XYZ
3 Tom Smith John Doe Do XYZ
4 Tom Smith Do XYZ
Tom Smith
1 John Doe Do XYZ
2 John Doe Tom Smith Do XYZ
3 Tom Smith John Doe Do XYZ
4 Tom Smith Do XYZ
----------------------------------------------------------------------------------
Originally I tried to use Access's Child/Master linking, but that
didn't work unless I used two subreports - Subreport 1 links Person 1
and Subreport 2 links Person 2 - but then you are limited by how you
sort.
I've been working on doing it through VBA in the Subreports Report_Open
in attempt to requery the subreport each time it is opened. The
criteria for the main report is determined through a series of
Multi-Select List Boxes. So I have passed that down to the subreport
and my SQL code looks like this. My problem is that the subreport
doesn't seem to update between occurences
Open Issues is the table that holds all of the subreport Data.
PersonName is the control in the main report that would normally be the
Master field.
stringPerson = "(OpenIssues.Person1 = """ & Me.Parent!PersonName.Value
& """ OR OpenIssues.Person2 = """ & Me.Parent!PersonName.Value & """)"
stringSQL = "SELECT DISTINCTROW OpenIssues.* " & _
"FROM OpenIssues " & _
"WHERE " & stringPerson & _
" ORDER BY OpenIssues-ID;"
Set db = CurrentDb
Set qdf = db.QueryDefs("queryOpenIssues")
qdf.SQL = stringSQL
Set db = Nothing
Set qdf = Nothing
Me.RecordSource = "queryOpenIssues"
-----------------------------------------------------------------------------------------------------------------------------
done.
It involves 1 Master Field and 2 Child Fields (which access can't seem
to deal with) so Im trying to go through VBA.
Simplified version of what im dealing with and my problem. There are
more parts to it, but I don't have any issues with those.
Report with 1 subreport. Main Report lists people by name. Subreport
Lists the responsiblities of the person in the main report. The tricky
part is that often 2 people are responsible for the same issue, the
subreport has two slots (person1, person2) to account for this. The
person listed in the main report could be in either slot. I need both
people on the list, rather than 2 records, because they are supposed to
work together to solve the issue.
Report Layout
--------------------------------------------------------------------------------
Person A
Issue-ID Person1 Person2 Issue 1
--------------------------------------------------------------------------------
Basically, I want it to come out like this.
--------------------------------------------------------------------------------
John Doe
1 John Doe Do XYZ
2 John Doe Tom Smith Do XYZ
3 Tom Smith John Doe Do XYZ
Tom Smith
2 John Doe Tom Smith Do XYZ
3 Tom Smith John Doe Do XYZ
4 Tom Smith Do XYZ
----------------------------------------------------------------------------------
What Im Winding Up With... (All records end up showing on both)
--------------------------------------------------------------------------------
John Doe
1 John Doe Do XYZ
2 John Doe Tom Smith Do XYZ
3 Tom Smith John Doe Do XYZ
4 Tom Smith Do XYZ
Tom Smith
1 John Doe Do XYZ
2 John Doe Tom Smith Do XYZ
3 Tom Smith John Doe Do XYZ
4 Tom Smith Do XYZ
----------------------------------------------------------------------------------
Originally I tried to use Access's Child/Master linking, but that
didn't work unless I used two subreports - Subreport 1 links Person 1
and Subreport 2 links Person 2 - but then you are limited by how you
sort.
I've been working on doing it through VBA in the Subreports Report_Open
in attempt to requery the subreport each time it is opened. The
criteria for the main report is determined through a series of
Multi-Select List Boxes. So I have passed that down to the subreport
and my SQL code looks like this. My problem is that the subreport
doesn't seem to update between occurences
Open Issues is the table that holds all of the subreport Data.
PersonName is the control in the main report that would normally be the
Master field.
----------------------------------------------------------------------------------------------------------------------------From subreport Report_Open
stringPerson = "(OpenIssues.Person1 = """ & Me.Parent!PersonName.Value
& """ OR OpenIssues.Person2 = """ & Me.Parent!PersonName.Value & """)"
stringSQL = "SELECT DISTINCTROW OpenIssues.* " & _
"FROM OpenIssues " & _
"WHERE " & stringPerson & _
" ORDER BY OpenIssues-ID;"
Set db = CurrentDb
Set qdf = db.QueryDefs("queryOpenIssues")
qdf.SQL = stringSQL
Set db = Nothing
Set qdf = Nothing
Me.RecordSource = "queryOpenIssues"
-----------------------------------------------------------------------------------------------------------------------------