Resizing a subform to show all records (1 Viewer)

OBBrock

New member
Local time
Today, 07:54
Joined
Jul 8, 2018
Messages
5
I have a form for all of our contacts.
It contains a subform of their donations, which I have been using in the datasheet view.
That works fine, except if I view a contact with many donations, I will see only as many donations as fit in the window. I would like to show them all, plus the open space in which an additional donation could be entered.

The goal is to show the user as much data as exists in the smallest space needed. This is because there are actually two subforms, and I would like the second one to be visible on the same screen when there are few subrecords.

I have changed the properties of the subform to make it a continuous form, because I understand that is necessary for this approach.

I found an example of code that is supposed to do what I want, on the microsoft forum, but I get a compile error, and I am not sure what to do about it. (I have very little experience with VBA).

The compiler seems to be having trouble with the second reference to "frmtblAppealDonationsSub" which is the name of the donations subform.

Here's the VBA I have so far

Private Sub Form_Resize()

On Error GoTo Form_Resize_Error

Me.frmtblAppealDonationsSub.Height = Me.InsideHeight - (Me.Section(1).Height + Me.frmtblAppealDonationsSub.Top + 100)
Me.frmtblAppealDonationSub.Width = Me.InsideWidth - 200

On Error GoTo 0
Exit Sub

Form_Resize_Error:

MsgBox "Error " & Err.Number & _

" (" & Err.Description & ") in procedure Form_Resize of VBA Document Form_frmMyQueryResults"
End Sub
 

JHB

Have been here a while
Local time
Today, 16:54
Joined
Jun 17, 2012
Messages
7,732
What is the error, number + message?
 

OBBrock

New member
Local time
Today, 07:54
Joined
Jul 8, 2018
Messages
5
Ah yes, that would help, wouldn't it? Thanks for your quick response, JHB

When I first open the contacts form I get the message

Compile error:
Method or data member not found

and the second occurrence of "frmtblAppealDonationsSub" (but not the first occasion--see above) is highlighted with blue color

"Private Sub Form_Resize()" is highlighted with yellow and a yellow arrow points to it.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 22:54
Joined
May 7, 2009
Messages
19,237
You dont need to do the rezinf of the subform. Use the Anchor Property of the subform.
 

OBBrock

New member
Local time
Today, 07:54
Joined
Jul 8, 2018
Messages
5
Thank you for your response arnelgp.
It seems that by anchoring the subform B, I will give it a try.
 

Users who are viewing this thread

Top Bottom