Search code examples
ms-accesstextboxvbareport

Access report "Can Grow" property needs to effect neighboring controls


I have a report with a bunch of controls in the Detail section. I am working off a word document that was given to me as a sample and I recreated it in access almost perfectly. What I need now is a way to handle overflowing the text boxes. I have "Can Grow" enabled, but here is the real issue:

I have a fake table going on. Multiple text boxes arranged in a way that just doesn't work in a subform. Certain cells have red, green or yellow backgrounds while others are just plain white. When one of the text fields overflows, and "grows", the other text boxes in the same row stay the same size as before and it looks very very odd (703 twips vs 300). I would really just love for it to work as if it were a table in word/excel and the entire row would grow at once (all =703 twips), but seeing as how it isn't literally a "row" I just want a way to associate the height of these text boxes with each other.

Is anything like this possible? If I need to clarify anything just let me know, I hope I've given ample information.


Solution

  • Ok here we go. So I had a fake table, I needed it to have table borders around each text box and when one text box got taller than the others in the row, the borders would look totally wrong. So, what we have to do is literally draw on the report at runtime, which can be done in any view including print preview. This code must be placed in the Print event

    'step one. find out which box in the row has the greatest height value. 
    'You can come across this information however you want. 
    'It will likely depend on what data goes in the boxes.
    'For the sake of the answer length we will skip that actual code
    
    'step two. Take measurements and store them in variables.
    'You will need a start point, and an end point in standard (x1,y1),(x2,y2) form.
    Dim t As Integer 'top
    Dim l As Integer 'left
    Dim b As Integer 'bottom
    
    'step three. Use these measurements and draw your lines.
    'Try to use looping if your naming and report layout work will allow it.
    Me.Line (l, t)-(l, b), RGB(0, 0, 0)
    '       (x1,y1)(x2,y2),pick a color
    'We just drew a line straight down the length of the control
    'If you plan ahead, and place a line on the report permanently on top of the first row
    'and below every row, you will only need to draw vertical lines.
    'The lines below each row will be pushed down by the tallest control
    

    I hope this helps. I had no idea this stuff existed before at all. Here is the MSDN info about it: http://msdn.microsoft.com/en-us/library/aa221362%28v=office.11%29.aspx