Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 1 / March 2006

Tip: Looking for answers? Try searching our database.

Report

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Igor - 01 Mar 2006 14:41 GMT
Hello! I'm trying to create a report, in which all of the textbox
controls in Detail section I'd like to resize to one size.

Here is a code (Access 2000):

Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
  Dim c As Control
  Dim MaxH As Long
On Error GoTo 999

  MaxH = MaxHeight(Me.Section(acDetail))
  SetControlsHeight Me.Section(acDetail), MaxH

999:
  Err.Clear
End Sub
'-----
Public Function MaxHeight(sec As Section) As Long
  Dim c As Control
  Dim MaxH As Long
On Error Resume Next

  For Each c In sec.Controls
     If c.Visible = True Then _
        If MaxH < c.Height Then MaxH = c.Height
     Next c
  MaxHeight = MaxH

End Function
'-----
Public Sub SetControlsHeight(sec As Section, H As Long)
  Dim c As Control
On Error Resume Next

  For Each c In sec.Controls
     If c.Visible = True Then
        c.Height = H
     End If
  Next c

End Sub

As a result I get a row, containing textbox controls with variable
heights.
What's wrong with my code?

Thanks!
Tim Marshall - 01 Mar 2006 15:25 GMT
> As a result I get a row, containing textbox controls with variable
> heights.
> What's wrong with my code?

I didn't look closely at your code, but disn't catch anything jumping
out at me on a quick scan (that's not to say it's 100%, mind you).
However, if you have the cangrow and/or canshrink properties of your
text boxes in the report set to yes, this could affect the sizes that
are being printed.  I would think with the code that you have I'd want
to make sure these properties are set to NO in report design view.  If
you haven't, try that and see if it helps...

Signature

Tim    http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Whatcha doin?" - Ditto  "TIM-MAY!!" - Me

bruce@aristotle.net - 01 Mar 2006 20:44 GMT
I'm not quite sure where is the most appropriate place to put the code
that you have in the Detail_Print event, but I know it won't work
there.  You can't resize controls in the detail print event.  You
should be able to put this code in the detail format event, or better
still in the report open event if you don't want it to run every time a
record is formatted for printing.

HTH,
Bruce
Igor - 02 Mar 2006 08:07 GMT
It doesn't work neither in the Detail_Print event, nor in then
Detail_Format event.
I can move controls (Me.TextBox.Top=277), but can't resize.
Why I can't change the height?
One of the controls can grow (CanGrow is set to Yes) and the heights of
each rows can be different.
So it doesn't better to put the code into the Report_Open event.
Really it is impossible to resize controls?

Thanks!
Igor Tsoy
bruce@aristotle.net - 03 Mar 2006 20:58 GMT
You can resize, but it appears that the CanGrow and CanShrink
properties of the controls will override whatever you do to resize the
controls.  What specifically are you trying to do?  There may be a
combination of settings of CanGrow and CanShrink on the controls and
the section that they are printing in that will do what you want.
Other than that the only option I could think of would be to set
CanGrow and CanShrink both to No and then rewrite your MaxHeight
function using the TextWidth and TextHeight functions to determine what
the actual height of your controls should be at run time.

Bruce
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.