访问2007年报告,隐藏字段?

时间:2015-12-23 19:04:46

标签: ms-access reporting

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

1 个答案:

答案 0 :(得分: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:")