Results 1 to 7 of 7
  1. #1
    cyanidem's Avatar
    cyanidem is offline Competent Performer
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2015
    Location
    Consett, UK
    Posts
    270

    Question Change Objects' Height On Report.

    Hi All,

    In my project I got report that I would like to resize depending on sizes of some elements. Because one picture is worth more than 1000 words,
    here's the picture:

    Click image for larger version. 

Name:	clip6.jpg 
Views:	12 
Size:	88.9 KB 
ID:	22957

    Selected textbox PONumber can contain just one 7-character PO number or 10 of them. Its Can Grow property is set to Yes and that works as expected. Now, let's have a look at another picture:



    Click image for larger version. 

Name:	clip7.jpg 
Views:	12 
Size:	89.4 KB 
ID:	22955

    I would like selected "border" around all Supplier information to grow as well. But because it's just a rectangle, it doesn't have Can Grow property.

    I tried to read PONumber.Height property @On Format event of report detail but it shows height BEFORE it grows - is it normal? How can I read its property when its grown already and set height of rectangle according to it?
    Or is there other way (I bet there is...) to achieve that?

    Thanks in advance
    Attached Thumbnails Attached Thumbnails clip8.jpg  

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    Certain properties can be managed during Run Time. Other changes to properties need to be done during Design Time. In order to accomplish Design Time changes to an object like a form or a report, you will need to open that object in Design View.

    If you want to change the Height property of a TextBox control you will need to be in design view of the parent object. These changes need to be made and saved during Design Time. This is unlike the Can Grow property that is available during Run Time.

  3. #3
    cyanidem's Avatar
    cyanidem is offline Competent Performer
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2015
    Location
    Consett, UK
    Posts
    270
    Ok, I think there's some misunderstanding
    So, from the start:
    My report is build from few different blocks. I separate these block using rectangle under other controls as a kind of border. One of the blocks is supplier information (as in picture) which contains textbox PONumber. This PONumber usually is only one per report (in format POXXXXX) but on some occasions it can be even 10 or more of them (like POXXXXX, POYYYYY, POZZZZZ etc.). I have textbox height set in design mode but I need it to grow in Run mode. And it grows, no problem, that's how Can Grow property works. What I need now is to determine size of grown up textbox and set height of that "border" rectangle. But when I try to do it in On Format event it shows me height of textbox before it grows up.
    I know for sure I can set height of objects during run time (in On Format event) because that's what I do in different part of the same report with pictures. What I don't know is how to get height of grown up textbox and then change size of other controls.

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    Quote Originally Posted by cyanidem View Post
    ... set height of that "border" rectangle. But when I try to do it in On Format event it shows me height of textbox before it grows up...
    As far as I know, the Height property is not available during Run Time. CanGrow is something different. So, if the height of an object after Cangrow does its song and dance is 600 TWIPS, you will not be able to assign that value to the Height property of another control during Run Time.

    You would have to open the Report in Design View. So something like this ...
    Code:
    DoCmd.OpenReport "ReportName", acViewDesign, , , acHidden
    Reports!Reportname.ControlName.Height = 600
    DoCmd.Save acReport, "ReportName"
    DoCmd.OpenReport "ReportName", acViewPreview, , "[MyIdField] = " & lngMyID
    If you cannot apply CanGrow to an object, this is the alternative.

  5. #5
    cyanidem's Avatar
    cyanidem is offline Competent Performer
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2015
    Location
    Consett, UK
    Posts
    270
    Quote Originally Posted by ItsMe View Post
    As far as I know, the Height property is not available during Run Time. CanGrow is something different. So, if the height of an object after Cangrow does its song and dance is 600 TWIPS, you will not be able to assign that value to the Height property of another control during Run Time.
    Well, sorry but you're wrong. I set height property of pictures in report in OnFormat event (which is Run Time, right?)
    Here's part of sub that's doing it:
    Code:
    Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
        Dim Args() As String
        
        Args = Split(Me.OpenArgs, ";")
        
        Image1.Picture = Args(0)
        If Args(0) = "" Then
            Image1.Height = 1
            Image1.Top = 9466
        Else
            Image1.Height = 4581 'twips = 8.08cm
            Image1.Top = 9466
        End If
    .................
    And it works, so it's definitely possible to set height in run time. I just can't read height property of grown up text box with Can Grow property set to Yes.

  6. #6
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    OK, I stand corrected and thanks. In fact, here is a reference that explains where and when you can do this.
    https://msdn.microsoft.com/EN-US/lib.../ff192846.aspx

    I also found a reference that states, starting with Access 2010, you can make Design Time changes to Forms by simply using acHidden in the Open method of the DocmdObject. In other words, no need for acDesignView. Which id very interesting to me.

    Having said that, It is not likely you will be able to get the value you desire from the Report Object during the OnFormat event. Apparently, according to the description you provided, Access is doing a black box thing at the same time the OnFormat event is firing. So you would have to retrieve the value after the OnFormat event.

    I guess you could open the Report twice. During the first rendering, you could assign the values to a custom Class and have Collections store the necessary information. Maybe use the Report's OnCurrent event and gather page number, control height etc.

  7. #7
    cyanidem's Avatar
    cyanidem is offline Competent Performer
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2015
    Location
    Consett, UK
    Posts
    270
    Thing is when I set heights and positions of pictures in that procedure above I refer to heights and positions of other objects (i.e. Image2.Top = Image1.Top + Image1.Height + 5), so it seems like Access can somehow read those values in OnFormat event. But for that textbox it won't show extended height, only that one set in design...
    Anyway, your idea with opening report twice and storing values gave me something to grab on, will see where it ends
    Thanks for your time and valuable input!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. How to set overall report height?
    By mcusuma1 in forum Reports
    Replies: 3
    Last Post: 06-11-2015, 09:49 AM
  2. How to change the height of the report form.
    By trident in forum Reports
    Replies: 6
    Last Post: 02-18-2015, 12:04 PM
  3. Change Height of Box to height of textBox
    By oxicottin in forum Reports
    Replies: 7
    Last Post: 03-15-2013, 09:54 PM
  4. Replies: 4
    Last Post: 09-15-2012, 07:31 PM
  5. Replies: 2
    Last Post: 01-14-2008, 12:15 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums