2015-12-23 121 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