Senin, 22 Februari 2016

RE: [MS_AccessPros] Show/Hide labels based on value in a field on a report

 

When I read "series of check boxes", I always plan on the series changing over time. This suggests the series should be records stored in a table. My table would have fields like:
 
tblCheckBoxes
======================
chkChkID       autonumber primary key
chkCaption   text for the caption property
chkOrder      number field that identifies the order the check boxes are displayed.
 
I would then create a subreport based on this table and drop it onto the main report. Then in the On Format event of the report section containing the check box  subreport, I would add code like:
 
Me.srptCheckBoxes.Visible =  Instr(Me![COMCDE_01],"B")> 0
 
WHEN (not if) you get asked to change the order of the number of boxes or the captions, you simply go to the table and make the changes, never to the design view of the report. Even better, have your users make the changes!
 
Duane Hookom, MVP
MS Access
 

To: MS_Access_Professionals@yahoogroups.com
From: MS_Access_Professionals@yahoogroups.com
Date: Mon, 22 Feb 2016 12:24:50 -0800
Subject: [MS_AccessPros] Show/Hide labels based on value in a field on a report



Hello everyone,


I have a set up reports in an Access 2003-based front end (linked to a SQL 2008 database) used for printing production orders.  The reports are identical, but are based are different queries (for selecting individual orders or ranges of orders based on different criteria).  I have been asked to add a series of "check boxes" to this report.  These "check boxes" should only be visible depending on whether or not certain code appears in a given field (called COMCDE_01) on the report (the same field appears in all of the reports/queries), and would not be something the users of these reports would actually select.  Instead, they're intended as a checklist for shop workers that would received the printed orders, to make sure that said workers complete certain production steps (the boxes would be checked in pen as the steps are completed).  I originally was going to use a set of unbound text boxes, with one text box per check box and the box the shop worker would check being the blank text box with it's borders visible.  I wanted to use conditional formatting to show/hide the boxes, but apparently this isn't possible with text box borders.  Instead, I found that I would have to use VBA code to accomplish this.  Here's my sample code for one of the text boxes:


Private Sub Text293()
IIf(Me![COMCDE_01] Like "*B*", Me!Text293.Visible = True, Me!Text293.Visible = False)


End Sub


I'm not looking for COMCDE_01 to equal a specific value, but rather to have the text box be visible if the COMCDE_01 field for a given order contained a "B" anywhere in the field (and have the text box be invisible if there is no "B" in the field).  Unfortunately the VBA debugger in Access (I'm using 2010) doesn't like this setup (it's expecting COMCDE_01 to equal something specific as a condition).


How can I resolve this dilemma?  I originally considered a label only, but couldn't figure out how to print a box-like symbol in a label (though I'm willing to just use an underscore instead (like ____ ).  I would greatly appreciate any suggestions on this.


Thanks in advance,
Michael


__._,_.___

Posted by: Duane Hookom <duanehookom@hotmail.com>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (3)

.

__,_._,___

Tidak ada komentar:

Posting Komentar