UtterAccess.com
We have detected that you are using an unsupported web browser. We recommend you to upgrade your web browser to get the most from UtterAccess forums.
Why should and how can I upgrade?
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> change SECTION height in the report - VBA way    
 
   
amigos
post Aug 4 2004, 04:37 AM
Post #1

UtterAccess Enthusiast
Posts: 62
From: London



hi guys
I have a problem
I have an Access report, with a lot of footers and headers and I need to be able to change a height of one of them, so far I tried (with the code):
base on [FIELD] value:
- change section.height property - can't be done on the fly
- change a height of vertical line it the section - it works fork but it changes the height of all sections that are printed afterwards which is not what I need - they must be the shorter again
- hide or show the line - the same result as above
- use textbox.TOP property - read only
any ideas???
thanks in advance
Go to the top of the page
 
+
Imitation9
post Aug 4 2004, 08:11 AM
Post #2

UtterAccess Veteran
Posts: 471
From: Little Rock, Arkansas



Have you tried setting the Can Grow property to Yes? That should allow the section (and that section alone) to grow based on the data in the section. If you want it to shrink Can Shrink might work.
Am I to understand that you tried putting an invisible line in the section and changing the height of the line when a certain event occurs?
Go to the top of the page
 
+
amigos
post Aug 4 2004, 08:26 AM
Post #3

UtterAccess Enthusiast
Posts: 62
From: London



Thanks for response Imitation,
roperties "can grow" and "can shrink" are set to YES already.
when condition occurs the section's height is changed but is not changed back afterwards when condition doesn't occour.
Thats one of code's examples:
If Me.[LEVEL_5] Like "Investment Portfolio" Then
Me.Text100.FontUnderline = True
Me.Line58.Height = 480
Else
Me.Text100.FontUnderline = False
Me.Line58.Height = 240
End If
it works fine for text box - the textbox in this footer is underlined
and it works fine for lines height - only line it this section is higher
the problem is that whole section stays higher afterwards - it doesnt "shrink back"
any more suggestions???
Go to the top of the page
 
+
Imitation9
post Aug 4 2004, 08:44 AM
Post #4

UtterAccess Veteran
Posts: 471
From: Little Rock, Arkansas



Okay I fully understand what you are talking about now.

In the OnOpen Event Procedure of the report:

Me.GroupHeader0.Height = YourHeight

You can change the height based on this in VBA. If possible (not sure) I would attempt to set the height equal to the height of your text box, so that it changes to match that value without your having to "hard code" the height.
Go to the top of the page
 
+
pbrep
post Aug 4 2004, 09:19 AM
Post #5

UtterAccess Member
Posts: 20



When ever working with heights through VBA, you have to add a statement to change the height back to the original height. If you only add code to make it larger, than it will always stay larger. Here is a basic example of this code.
If page = 1 Then
pageheader.height = 1000
Else
pageheader.height = 200
End if
Go to the top of the page
 
+
amigos
post Aug 4 2004, 09:46 AM
Post #6

UtterAccess Enthusiast
Posts: 62
From: London



pbrep : thanks for response - take a look at my code above - it does ELSE thing...
mitation9:
it still doesnt work
OnOpen event I got:
Me.GroupFooter1.Height = MyHeight
end OnFormat of Footer (as I want only this footer to be higher for that particular Portfolio):
If Me.[LEVEL_5] Like "Investment Portfolio" Then
MyHeight = 480
Else
MyHeight = 240
End If
but it still doesnt work :(
if I try:
If Me.[LEVEL_5] Like "Investment Portfolio" Then
Me.GroupFooter1.Height = 480
Else
Me.GroupFooter1.Height = 240
End If
Ogot error that Height cant be changed after printing started...
any suggestions?
Go to the top of the page
 
+
Imitation9
post Aug 4 2004, 11:52 AM
Post #7

UtterAccess Veteran
Posts: 471
From: Little Rock, Arkansas



MyHeight was meant to be the numerical value you were going to assign to that (i.e. 480 or whatever)

CODE
If Me.Level_5 Like "Investment Portfolio" Then
nbsp;    Me.GroupFooter1.Height = 1000
Else
     Me.GroupFooter1.Height = 500
End If


Otried a variation of that on one of my reports. Using a small number of Pixels made the changes almost invisible. When I increased the number of pixels I could tell a difference and the above code worked. I did 5000 and 2500 pixels and it put about a 2 inch gap on my page in regards to the criteria in the if statement.

HAs far as the error I am unsure. You are probably trying to get this to change in the OnPrint event procedure of the Report. Either that or you are working with a command button that will not 1st open the report then print. I put my code in the OnOpen event procedure of the report, so I would have to open the report before printing so that the changes would take effect.

Edited to tell you that I know why it worked for me and not for you. Worked because my criteria was Page number, your's is a value in a control. The control value won't work in the OnOpen event procedure, so I will see if I can find something that will work.

Edited by: Imitation9 on 08.04.04.

I can get it to work (sorta) in the OnPage event - code runs prior to printing. The only problem is it took my criteria and and only formated the first record in the group and not the records that contained the criteria.
Edited by: Imitation9 on 08.04.04.
Go to the top of the page
 
+
amigos
post Aug 4 2004, 04:10 PM
Post #8

UtterAccess Enthusiast
Posts: 62
From: London



I put
If Me.[LEVEL_5] Like "Investment Portfolio" Then
Me.GroupFooter1.Height = 480
Else
Me.GroupFooter1.Height = 240
End If
in OnFormatevent of Footer and it caused that error :(
Odont see any difference between my code and yours
anyway I am going for holidays tommorow which means that I will come back to this problem in 2 weeks time
thank you for your time and effort
I will let you know as soon as I solve this problem out
Thanks again
Go to the top of the page
 
+
CCCMAx
post Apr 23 2012, 01:29 PM
Post #9

New Member
Posts: 1



I have tried your suggestions to no avail. Detail section grows but does not shrink for subsequent records. It is set to can grow/can shrink, as is the text box in the detail section.
My Code:
Private Sub Report_Open(Cancel As Integer)
Me.Detail1.Height = 1440 * 0.3329
End Sub
If Me!LStep > 50 Then
Me.Detail1.Height = 1440 * 0.68
Me!Line380.Height = 1440 * 0.68
else
Me.Detail1.Height = 1440 * 0.3329
Me!Line380.Height = 1440 * 0.3326
end if
Me!LStep is working correctly and shows the correct number on each detail record. Still cannot get the detail section to shrink back down.
Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Search  ·  Go to Top  ·  Lo-Fi Version Time is now: 22nd October 2014 - 05:25 PM