Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Detail section expands on new record?

Status
Not open for further replies.

PeteG

Programmer
Feb 23, 2001
144
GB
Hi,

I have a (continuous) form bound to a table, so the two textboxes that I have in the detail section appear multiple times depending on how many records I have in my related table. What I am looking to do is to expand the height of the detail section so that, if the user adds new records (via the new record row of the detail section) all of the records will still be shown regardless of the number of records that I have.

Is there a property of the detail section that I can set to accomplish this, or should I perhaps be checking the number of records (say, on the textbox_afterupdate event) and then programatically increasing the height of the detail section if I decide that I need to?

Just in case it isn't clear, I'm trying to keep the form nice and compact. I have header, detail and footer sections and I want the detail section to only be as tall as it needs to be to display all of the bound records - so it should expand when a new record is entered (and, I guess, decrease in height when one is deleted)

Thanks for any advice.
 
How are ya PeteG . . .

You understanding of the detail section of a form in continuous view, needs tweaking! ...
TheAceMan1 said:
[blue] ... whatever space you add to the
Code:
[blue]detail section[/b][/blue] of a form ... is [blue][b]accumulated[/b][/blue] in each record in form view!

The above should tell/show you how no spacing in the [blue][b]detail section[/b][/blue] affords the maximum records that can be viewed. From there its a matter of your screens resolution asd o how things perk-up!

 [COLOR=DarkGoldenRod][b]See Ya! .  .  .  .  .  .[/b][/color]

Be sure to see faq219-2884  [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886  [blue]Worthy Reading![/blue] [thumbsup2]
 
Hi AceMan, thanks for your post. I'm sure my understanding *does* need a little tweaking! I haven't used Access for a little while and just starting to feel my way a bit now.

I understand what you say about having no vertical spacing to be able to view the most records that I can in the detail section. However, what I am asking is whether there is a property that will automatically keep my header, detail and footer data viewed tight together. For example, if my text boxes are, say, 1cm deep then I want the detail section to be 1cm deep when it first opens. As soon as the user tabs into the first row, a second (new) row is created and so I want my detail section to expand to 2cm deep at that point. And so on and so on until I hit some limit or even the data starts scrolling off of the screen.

I can't see anything that does that automatically and so I am wondering whether the only way is to add some code to an event (textbox afterUpdate, or form beforeInsert maybe), to adjust the height of the detail section as I go?

I'm trying to avoid two things really
1) I don't want an expanse of open space in my detail section if I only have one or two records to show. I want the footer data to follow on immediately from the detail.
2) When there are enough records to fill the detail section, the data within the detail section scrolls independently of the footer data. The footer data stays where it is on screen and the top rows of the detail section scroll out of view (because there are now too many records to show within the space available for the detail). I would rather that, at this point, the footer section moved down to allow all of the detail data to still be seen.

Thinking about this, my question is more about the behaviour of the footer section. I don't want it 'docked' at the bottom of the form; I want it 'floating' always immediately beneath the detail.
 
PeteG said:
... so I am wondering whether the only way is to add some code to an event (textbox afterUpdate, or form beforeInsert maybe), to [purple]adjust the height of the detail section[/purple] as I go?
I've already explained what happens when you adjust (add space) to the details area. And no ... there is no such property to handle this!

You also need to consider that when the db is moved to a system with a [blue]different screen resolution[/blue], all your adjustments and calculations will go right out the window!

There is a header height, footer height, and the rest (details) depends on the height of the form. If you want to program this its your choice.

[blue]Your Thoughts . . .[/blue]


See Ya! . . . . . .

Be sure to see faq219-2884 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
You can try code like the following which will display the existing records plus the blank. If you don't want to display the new record row, remove the + 1.

Code:
Private Sub Form_Current()
    Me.InsideHeight = (Me.RecordsetClone.RecordCount + 1) * Me.Section(0).Height + Me.Section(1).Height + Me.Section(2).Height
End Sub

Duane
Hook'D on Access
MS Access MVP
 
Thank you both. I understand now that there is no setting to do this by default and, hoookdm, your code solution works perfectly for what I was trying to explain, when I open my form as a 'pop-up'. However, my form is a sub-form on a tab control page and unfortunately that behaviour gets lost.

It is not an essential requirement for me so I probably won't pursue it any longer but thanks for taking the time to go through this.
 
"However, my form is a sub-form on a tab control page"
Don't you think this was significant and should have been mentioned in your first post?

Please, in the future provide all of the significant information so those who attempt to provide assistance don't waste time.

Duane
Hook'D on Access
MS Access MVP
 
Yes and yes. However, those who aren't as experienced as you don't necessarily know what is significant and what is not, at the outset of a question.

Apologies if I've wasted your time.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top