Senin, 17 November 2014

RE: [MS_AccessPros] Resize a report vertically if the fields are empty

 

Carlo,
 
Can't you set the Can Shrink properties of the controls and Section to Yes?
 
BTW: 60 fields suggests your tables aren't normalized. I could be wrong since I don't know anything about your system.
 
Duane Hookom MVP
MS Access
 

From: MS_Access_Professionals@yahoogroups.com
To: MS_Access_Professionals@yahoogroups.com
Date: Mon, 17 Nov 2014 09:48:11 -0800
Subject: [MS_AccessPros] Resize a report vertically if the fields are empty



I would like the report to be present only the fields that have content.
In particular the report organized in column
has about 60 fields, which would occupy about 2 pages.

Of these 60 fields are filled in only 20-30, in a completely random

By using the system shows if the field is not empty, however, would take up 2 pages.
To Shorten the report only to fields that have a value
I renamede the fields: txt1 ... txtn
and apply formatting of the report on the following code.



Private sub Detail_Format(Cancel as Integer, FormatCount as Integer)
    Dim blPrevControlIsVisible As Boolean
    Dim lngTop as Long
    Dim lngLeft as Long
    Dim ctl As Access.Control
    Dim i As Integer
    For i=1 to 60
           Set ctl=Me.Controls("txt" & i)
           If blPrevControlIsVisible =True then
              ctl.Top=lngTop
              ctl.Left=lngLeft
           End if
           If Len(ctl.value & vbNullstring)=0 Then
              blPrevControlIsVisible=true
              ctl.Visible=False
              lngTop=ctl.Top
              lngLeft=ctl.Left
           Else
              blPrevControlIsVisible =False
           End if
    Next i
end if



Everything works fine if for example the first 20 fields (txt1 ... txt20) have a value and the next do not have a value

However, if, for example, the top 5 have a value (txt1 txt5 ...), the next 5 do not have a value (txt6 ... txt10) and the rest have value.

I get the following
txt1
txt2
txt3
txt4
txt5
txt11
space corresponding (vertical to: row)
txt6
txt7
txt8
txt9
txt10
then picks up
txt12
txt13
txt14
txt15
txt16
txt17
etc ..

txt11 takes the coordinates of txt6 but
It seems that txt12 not reposition vertically below txt11
It remains the gap between txt11 and 12 txt equal to five line

I tried to change the code to no avail.
There is an error that can not find


Anyone have any ideas ???





__._,_.___

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 (2)

.

__,_._,___

Tidak ada komentar:

Posting Komentar