Move subform

D

Daniel

I have two subform on a main form. Both subforms are used to seperate a
recordset(a list of dated events for expected recovery from injury) based on
a user entered date. The forms will then display which actions are completed
or future. For example if there are 12 records they might be seperated as 8
on one subform and 4 on the other.

The total number of records can very form 6 to 15 seperated over the two
subforms.

The problem I am having is with the position of the subforms. I have been
able to size the individual subforms based on height of field*recordcount.
Sometimes though the top subform overlaps onto the lower subform.

Is there any way that I can use VBA code to move the lower subform so that
it will always be the same distance from the bottom of the upper subform?
Hope that makes sense.
 
D

Duane Hookom

Could you provide the code you use "to size the individual subforms based on
height of field*recordcount"?
 
D

Daniel

Here is the code I have used.

Private Sub Form_Open(Cancel As Integer)
Dim rccnt As Integer
Dim hght As Integer

hght = 500
rccnt = Me.RecordsetClone.RecordCount

Me.Form.InsideHeight = hght * rccnt + Me.FormHeader.Height +
Me.FormFooter.Height
End Sub

I wanted all the records to be diplayed without the users having to scroll.

I tried autoresize but it didn't have the desired effect.

At the moment the gap between the forms is too large, but it is the only way
to keep the forms from encroaching on each other.
 
D

Duane Hookom

I would use code in the main form to count the records and resize the subform
control of the top form. Then find the Top + Height of the top subform to set
the Top of the lower subform.

BTW: You should consider posting this only to the Form news group where it
is more appropriate than the report news group.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top