• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 53
  • Last Modified:

How have report show detail if a form checkbox is true

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
SteveL13
Asked:
SteveL13
  • 5
  • 4
1 Solution
 
crystal (strive4peace) - Microsoft MVP, AccessRemote Training and ProgrammingCommented:
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
 
SteveL13Author Commented:
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
 
crystal (strive4peace) - Microsoft MVP, AccessRemote Training and ProgrammingCommented:
oh, then you want the data filtered.  Are you using DoCmd.OpenReport?
0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
SteveL13Author Commented:
Yes...

DoCmd.OpenReport "rptAudit", acViewPreview, "", "", acNormal
0
 
crystal (strive4peace) - Microsoft MVP, AccessRemote Training and ProgrammingCommented:
> "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
 
SteveL13Author Commented:
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
 
crystal (strive4peace) - Microsoft MVP, AccessRemote Training and ProgrammingCommented:
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
 
SteveL13Author Commented:
Perfect!  Thank you very much.
0
 
crystal (strive4peace) - Microsoft MVP, AccessRemote Training and ProgrammingCommented:
you're welcome ~ happy to help
0

Featured Post

Free recovery tool for Microsoft Active Directory

Veeam Explorer for Microsoft Active Directory provides fast and reliable object-level recovery for Active Directory from a single-pass, agentless backup or storage snapshot — without the need to restore an entire virtual machine or use third-party tools.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now