Solved

MS Access subreport selection from list box

Posted on 2011-02-23
7
421 Views
Last Modified: 2012-05-11
It has been a long time since I have worked regularly with MS Access and Access reports, but I am working on an upgrade to an existing system and I am having some issues selecting data for a subreport. I have a listbox where the user can select up to 4 items, and a report with 4 subreports in it.  Is there a way to link each subreport to a selection in the listbox with the vba code?  
0
Comment
Question by:bnrtech
  • 3
  • 3
7 Comments
 
LVL 19

Expert Comment

by:MINDSUPERB
ID: 34960388
Do the Link Master Fields and Link Child Fields could not handle the link?

Ed
0
 

Author Comment

by:bnrtech
ID: 34960440
Im not sure I follow what you are trying to say.
0
 
LVL 19

Expert Comment

by:MINDSUPERB
ID: 34960526
In the Property Sheet of the Report in Design View, you can set the property of Link Master Fields and Link Child Fields under the All tab.

Basically, those link properties are commonly and effectively used in linking the data of your subreports based on the value in the main report. Try  to use it and see if it is already enough to handle the links you want.


Ed
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 84
ID: 34960569
I believe that the author wishes to show/hide a SubReport based on user selections in form?

If so, you can refer to this during the Open event of your Report, and then show/hide your Subreport based on that. Assuming that your SubReport CONTROL (i.e. the CONTROL on the main Report that is showing the subreport) is named EXACTLY as what is appearing in your listbox:

Dim i As Integer

For i = 0 To Forms("YourForm").YourListbox.ListCount - 1
    Me.Controls(Forms("YourForm").YourListbox(i)).visible = Forms("YourForm").YourListBox(i).Selected = True
Next i

Be careful referring to the SubReport CONTROL. This control has a Property named "Source Object" (which determines which Report is shown) - make sure to look for that Property to insure you're looking at the right control (for naming purposes).
0
 

Author Comment

by:bnrtech
ID: 34960615
Actually, I want to show all four at the same time if possible based on what is selected by the user.  If the user select a, b, c,d.  I need the data for a to show in subreport 1, b in 2 and so on, giving a quad chart appearance.
0
 

Author Comment

by:bnrtech
ID: 34960619
I am just having trouble selecting the data based on those selections
0
 
LVL 19

Accepted Solution

by:
MINDSUPERB earned 500 total points
ID: 34960676
I may suggest to use 4 different list boxes and assigned one list box to each subreport by linking them using the properties I posted at ID: 34960526.

You may hardly do VBA - ? - with one list box having 4 unique information selected.

Sincerely,
Ed
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now