Results 1 to 12 of 12

Thread: [VBA] Change size of label

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Apr 2007
    Posts
    174

    Wink [VBA] Change size of label

    Hello,
    I have an Access report. At the "onFormat" event I want to change the "height" of an element.
    There is a line around this element (a box), so I check for the change of size.
    So I tried:
    Me.myElement.Height = 5
    And this does work. I get a line (i don't even see the data).
    But when I actually try to make the height very large for example 50, the maximum the box will grow on is whather space the text take.

    How can I fix that ? Is there something I am doing wrong ?

    The reason why I am trying to do this:
    I have different info in my report
    For example:
    Info 1, Info 2, Info 3... and so on
    When I generate my report each one of them is surrouned by a box (ie, border = solid).

    Info 3 is a bit like a memo.
    My problem right now is that the box around info 1 is not equal to the box around info 2 or info 3... I want to have all the boxes size to be equal to the largest.
    So that's why I have to know how to set the height programatically so that when the report is generated it sets the heigh of the boxes to the height of the "tallest" box.
    But if you have a way around let me know please !

    thanks !


    >>>>> UPDATE :
    I fixed part of my problem.
    I disabled the "Can grow" and "Can Shrink"
    My issue now is for EACH detail i want to find the tallest size ( i know how to do that), but I don't know how in the "OnFormat" event do it for EACH detail in the report... right now it does it for everything... all the details box are the same....
    please help,
    thanks

    >>>>> MORE UPDATE :

    I did figure out to force the size of the fields. (the cangrow and canshrink have to be set to false)
    My problem is that I want all the fiels to be the same size as the field with the tallest size.
    The fields (Memo, and Description) are the tallest one no matter what.
    So I want to do a check to see which one of the two is the tallest and then set the size of everything else equal to the tallest.

    So right now I have in the OnFormat event:


    If Me.Memo.Height > Me.Description.Height Then
    Me.Field1.Height = Me.Memo.Height
    Me.Field2.Height = Me.Memo.Height
    Me.Field3.Height = Me.Memo.Height
    Me.Field4.Height = Me.Memo.Height
    Me.Field5.Height = Me.Memo.Height
    Me.Field6.Height = Me.Memo.Height

    Else
    Me.Field1.Height = Me.Description.Height
    Me.Field2.Height = Me.Description.Height
    Me.Field3.Height = Me.Description.Height
    Me.Field4.Height = Me.Description.Height
    Me.Field5.Height = Me.Description.Height
    Me.Field6.Height = Me.Description.Height

    End If


    PROBLEMS:
    Right now this does not work.
    BUT if I give a number instead of "Me.Descriptionm.Height" or Me.Memo.Height
    Everything works properly.
    I think it's because I have to write the code in a way so that it's applied to each "detail" iteration. I am not sure how.


    The other problem is that the Memo and Description field are both set to "Cangrow" yes.
    So that I know big they get.
    Let's say Memo is bigger than description. I will want to set Description at the same size as Memo.
    But I can't, because "Cangrow" is set as yes. And it does not look like I can change this setting from VBA...

    Please help, it's a bit hard to understand, but I have been stuck for a long time on this one.

    I am doing all of this to have all the solid lines around the fields sized the same. Because if I enable the cangrow option, i will a nice box around each field, but each one of them is different size... so it's looks a bit weird for a "table" type report.

    Thanks for your help
    Last edited by Zoroxeus; Jun 11th, 2007 at 10:52 AM.

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: [VBA] Change size of label

    Moved to Office Development forum

  3. #3
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [VBA] Change size of label

    What you need to do is create a couple of module level variables to hold the dimensions of the label. Then check it against the current label in the detail section. If the label is larger then increase the var size but if its not then use the var size for the dimensions of the label. Only issue will be previously formatted lables will not update to any newly increased sizes.

    Can you post a small screen shot of your report and a before and after look of how you need it?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Apr 2007
    Posts
    174

    Re: [VBA] Change size of label

    Hey RobDog888
    thanks for replying

    I am attaching you the picture.
    I am not sure what you meant by the multiple module thing.
    But the picture is pretty clear.

    I asked on an Access forum, and they had no idea... so it may be a bit challenging.
    I am a bit new to that whole access report thing... i always managed to get things done... but this time it's a bit of a trouble wrt the way i want my report...
    thanks for help
    Attached Images Attached Images  

  5. #5
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [VBA] Change size of label

    Ah, easy (I think)!

    Instead of using the label border outlining just draw lines and position the horizontal leveling at the bottom of the tallest label for that detail record and adjust the length of the vertical lines so they are all the same lengths.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Apr 2007
    Posts
    174

    Re: [VBA] Change size of label

    Not sure what you mean ? I am going to have the same issue I think !

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Apr 2007
    Posts
    174

    Re: [VBA] Change size of label

    my point is that for each detail the tallest change so it has to be in a way where the size is adjusted for EACH detail

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Apr 2007
    Posts
    174

    Re: [VBA] Change size of label

    Well I tried this:



    Report_a.Line31.Top = Report_a.Descri.Height
    Report_a.Line39.Height = Report_a.Descri.Height
    Report_a.Line40.Height = Report_a.Descri.Height
    Report_a.Line41.Height = Report_a.Descri.Height

    (it's a monlet test, so there is no comparisons between the two fields and all that)


    Line31 is the horizontal line and this works fine it goes as low as the line from description.
    Line39, 40, 41... are the vertical lines. This does not seem to work.... ? They stay at the same size

    I did a message box, for the value of Report_a.Descri.Height
    it stays the same at for every single detail. So that's the problem.



    getting there....

    thanks !
    Last edited by Zoroxeus; Jun 12th, 2007 at 08:19 AM. Reason: fixed typos

  9. #9
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [VBA] Change size of label

    See the light has turned on

    Ok, for the height dont use the detail height but eval each label to see which is the tallest and then use that value to adjust the vertical line lengths of all in that section.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Apr 2007
    Posts
    174

    Re: [VBA] Change size of label

    RobDog,
    I am not sure what you mean by "eval each label" to see which is the tallest.
    What would it change ?
    And also ONLY "description" and "memo" get bigger than everything else.
    But again, why this way would not work ?
    thanks

  11. #11

    Thread Starter
    Addicted Member
    Join Date
    Apr 2007
    Posts
    174

    Re: [VBA] Change size of label

    Does not seem to work...
    It is strange because the two vertical lines at the extremities are taller than the rest... but still they don't reach to the horizontal line

    I think it is the whole "if" thing that is posing problem.

    At the format event I have:
    [Report_Generic Report].Line31.Top = [Report_Generic Report].Descri.Height

    This is the horizontal line, and it works perfect.

    Then I have
    If [Report_Generic Report].Descri.Height >= [Report_Generic Report].Remarks.Height Then

    [Report_Generic Report].Line47.Height = [Report_Generic Report].Descri.Height
    else
    end if

    and this does not seem to work.

    It makes my original line smaller.

    --
    There seems to be something wrong with my code.
    I don't think "height" of a label is the same as "height" of line.
    When i ask to display height of label it gives me "270" ... ??

    When height is like 5.3 cm for example
    Last edited by Zoroxeus; Jun 13th, 2007 at 08:42 AM.

  12. #12

    Thread Starter
    Addicted Member
    Join Date
    Apr 2007
    Posts
    174

    Re: [VBA] Change size of label

    I attached the db file...
    thanks if you can take a look at it....
    It does not matter what I do... the number I get is always "270" ....
    (mdb file is renamed as zip)
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width