I would suggest a simpler approach. Create a temporary table in Access, with two fields: FieldNumber and FieldText. Loop through your fields, and, if a field is not empty, write a record to the temp table. You can easily report the contents of the temp table without any code at all.
Stuart
On Monday, November 17, 2014 1:01 PM, "carlo.scaroni@yahoo.com [MS_Access_Professionals]" <MS_Access_Professionals@yahoogroups.com> wrote:
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.
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
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 ???
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: Stuart Schulman <stoughy@yahoo.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