2015-12-23 67 views
0

我在Access 2007中有一个报告,它填充了来自SQL SERVER(在vb6应用程序上运行)的数据。该报告有两个显示数据的子报告。第一个子报表有一个标签,“CHILDREN”及其旁边的子报表显示了子女的姓名。第二个子报表有一个标签“PETS”,旁边的子报表显示PetName和TypeOfPet。在大多数情况下,每个家庭都有宠物,但是,对于一些客户来说,没有宠物。我想要做的就是让标签PETS在没有宠物的情况下不可见,因此标签本身不在报告中。我会怎么做呢?这是我必须编码的东西吗?Access 2007报告,隐藏字段?

回答

1

下面的链接显示了如何隐藏标签,如果没有数据:https://forums.techguy.org/threads/solved-access-2003-hide-field-labels-on-reports-when-value-is-null.660825/

下面是所需的步骤:

1. Delete the label from the text box. 
2. Add new text box in place of the old label. 
3. Format the new text box same as other label. 
4. Set it's "Can Shrink" property to "Yes". 
5.Bind the 'new' label to an expression that will solve to "" if the [Pet] field is blank or to the text string "Pets:" if the [Pet] field is not blank. 
6. Change text box Control Source field on the Data tab of the Properties window. In it put: 
    iif(isnull([Pet]),"","Pets:") 

This will put a zero-length string into the text box when the [Pet] field is null and the text "Pet:" when it is not null 

7. If the field is blank, it could be null or a zero-length string (""), or could have any number of blank spaces in it. Rather than use "IsNull", use a combination of functions that will solve. i.e.: 

Iif(trim(nz([Pet],""))="","","Pets:") 
+0

你达人!谢谢! – barry17