?
Solved

How have report show detail if a form checkbox is true

Posted on 2016-10-15
9
Medium Priority
?
45 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
[X]
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
  • 5
  • 4
9 Comments
 
LVL 22
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 22
ID: 41845106
oh, then you want the data filtered.  Are you using DoCmd.OpenReport?
0
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 

Author Comment

by:SteveL13
ID: 41845111
Yes...

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

Accepted Solution

by:
crystal (strive4peace) - Microsoft MVP, Access earned 2000 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 22
ID: 41845148
you're welcome ~ happy to help
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Suggested Courses

764 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