Solved

How have report show detail if a form checkbox is true

Posted on 2016-10-15
9
18 Views
Last Modified: 2016-10-15
I have a report that has detail records showing.  One of the fields on the report record is chkbxPendingReturn.  But first a form is opened that has a field named chkbxPendingReturn on it.  If the forms checkbox is checked then I want the detail record to show on the report.  But of the forms checkbox is not checked then I do not want the record to display on the report.  

How can I do this?

--Steve
0
Comment
Question by:SteveL13
  • 5
  • 4
9 Comments
 
LVL 19
ID: 41845070
terminology correction: forms and reports have controls, not fields. A control can contain a field.

on the report OPEN event:
me.detail.visible =  nz(forms!Formname!chkbxPendingReturn,true)

Open in new window

this will display or show the whole detail section. If you meant just one control, this can be changed.
0
 

Author Comment

by:SteveL13
ID: 41845095
This didn't work.  With the suggested code no detail records display if the checkbox on the form is false.  If I marked it true on the form, then all records display.

If the checkbox is true, then I only want the records to display on the report that have the field on the report chkbxPendingReturn as true.  If I mark it false then I want all of the records to display on the report.  I maybe didn't make it clear in the original post.
0
 
LVL 19
ID: 41845106
oh, then you want the data filtered.  Are you using DoCmd.OpenReport?
0
 

Author Comment

by:SteveL13
ID: 41845111
Yes...

DoCmd.OpenReport "rptAudit", acViewPreview, "", "", acNormal
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 19
ID: 41845122
> "But first a form is opened that has a field named chkbxPendingReturn on it"

do you mean it has a control with that name?
What is the Control Source? (that is the field)

If the control is unbound, it won't have a control source -- still need to know which field name it correlates to
   'declare variable(s)
   dim vWhere as variant
   'initalize value(s)
   vWhere  = null
   ' ... put code in to construct vWhere -- we need to discuss this more

   DoCmd.OpenReport "rptAudit", acViewPreview,  , vWhere

Open in new window

0
 

Author Comment

by:SteveL13
ID: 41845131
The checkbox on the form is unbound.  The reports record source is a query.  That query has a field named PendingReturn.

Does that help?
0
 
LVL 19

Accepted Solution

by:
crystal (strive4peace) - Microsoft MVP, Access earned 500 total points
ID: 41845138
Yes. PendingReturn needs to be ON the report (it can have Visible=No if you don't want it to show)

replace "' ... put code in to construct vWhere -- we need to discuss this more" with:
   if nz(me.chkbxPendingReturn,false) = true then
      vWhere = "PendingReturn =true"
   end if

Open in new window

assuming PendingReturn  is a Yes/No field in the source table
0
 

Author Closing Comment

by:SteveL13
ID: 41845144
Perfect!  Thank you very much.
0
 
LVL 19
ID: 41845148
you're welcome ~ happy to help
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

744 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

13 Experts available now in Live!

Get 1:1 Help Now