Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

How have report show detail if a form checkbox is true

Posted on 2016-10-15
9
36 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
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 

Author Comment

by:SteveL13
ID: 41845111
Yes...

DoCmd.OpenReport "rptAudit", acViewPreview, "", "", acNormal
0
 
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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
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 stored procedures 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 Micr…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

856 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