Resize form to fit in Subform Control

strager

Member
Local time
Today, 02:49
Joined
Apr 16, 2024
Messages
37
I made my own navigation form where I use the SubForm control to switch forms in and out. It is working great except I have a few forms that I can't resize to fit nicely in the subform control. see image I've been struggling with this for a few weeks and have tried numerous things. My latest attempt was to try and implement isladogs Move Forms & Controls example... but I can't get it to resize.
I've tried using the onResize event of a form and even though I see the difference in sizes between the Custom Nav form and the form I am adding to the SubForm control, it just flickers and doesn't resize.
I have the anchoring for the form controls, ie. listbox, subform, tabcontrol etc. set to down and accross.
I've also tried adding a procedure to my on side button click and even added Refresh to see if that gets it to work, but no luck.
Anyone have any ideas about this?
Thanks,
Sheri

SampleBillTracker.jpg


Private Sub ResizeLaunchedForm(ByRef sFrm As Access.Form)
Dim iHeight As Integer, iWidth As Integer
Dim igrpTopMenuH As Integer, igrpTopMenuW As Integer
Dim igrpSideMenuH As Integer, igrpSideMenuW As Integer
Dim iNavSubH As Integer, iNavSubW As Integer
Dim iFrmHeadH As Integer, iFrmHeadW As Integer
Dim iFrmDetailH As Integer, iFrmDetailW As Integer
Dim iFrmFootH As Integer, iFrmFootW As Integer
Dim iFrmTotalH As Integer, iFrmTotalW As Integer
Dim iNavFrmDetailH As Integer, iNavFrmDetailW As Integer
Dim iNavWindowW As Integer
Dim iTotalWidth As Integer, iTotalHeight As Integer
Dim fNav As Access.Form, iNavBarH As Integer
Dim sSub As SubForm
Dim cnt As Control, iCntH As Integer
Dim gSide As OptionGroup
Dim gTop As OptionGroup
Dim iLaunchedHeader As Integer

iHeight = sFrm.WindowHeight
iHeight = sFrm.InsideHeight
iWidth = sFrm.WindowWidth

With sFrm.Section(acHeader)
iFrmHeadH = IIf(.Visible, .Height, 0)
End With

With sFrm.Section(acDetail)
iFrmDetailH = IIf(.Visible, .Height, 0)
End With

With sFrm.Section(acFooter)
iFrmFootH = IIf(.Visible, .Height, 0)
End With

iFrmTotalH = iFrmHeadH + iFrmDetailH + iFrmFootH

Set fNav = Forms!frmCustomNav.Form


Set cnt = fNav.fSubForm
If TypeOf cnt Is SubForm Then
iNavSubH = cnt.Height
iNavSubW = cnt.Width
End If
'
Set gSide = fNav.grpSideMenu
igrpSideMenuH = gSide.Height
igrpSideMenuW = gSide.Width

Set gTop = fNav.grpTopMenu
igrpTopMenuH = gTop.Height
igrpTopMenuW = gTop.Width
'
iNavBarH = fNav.navHeader.Height
iNavFrmDetailH = fNav.Section(acDetail).Height
iNavFrmDetailW = fNav.InsideWidth

iTotalHeight = iNavFrmDetailH + igrpTopMenuH + iNavBarH '+ igrpSideMenuH '- igrpTopMenuH - iNavBarH

'iLaunchedHeader = sfrm.Section(acHeader).Height

'iTotalHeight = iNavFrmDetailH + iLaunchedHeader '- igrpTopMenuH - iNavBarH
'iTotalWidth = iNavFrmDetailW '- igrpSideMenuW

sFrm.Section(acDetail).Height = iTotalHeight '+ iLaunchedHeader

sFrm.InsideHeight = iTotalHeight '+ iLaunchedHeader
sFrm.InsideWidth = iTotalWidth

End Sub

Public Sub LaunchNavSideForm(ByVal sFormName As String, ByVal LWidth As Long, ByVal LHeight As Long, ByRef sFrm As Access.Form)
Dim sSubForm As Access.Form
Dim sName As String
Dim sFrmLaunch As Access.Form
Dim fSubForm As SubForm
Dim fNav As Access.Form
Dim iNavSubH As Integer

Set fNav = Forms!frmCustomNav.Form

sFrm.fSubForm.SourceObject = sFormName

Set sFrmLaunch = ReturnCustomNavForm

If Not sFrmLaunch Is Nothing Then

'sFrmLaunch.InsideHeight = LHeight
'sFrmLaunch.InsideWidth = LWidth
' sFrmLaunch.Detail.Height = LHeight
sName = sFrmLaunch.Name

iNavSubH = fNav.Section(acDetail).Height
sFrmLaunch.Section(acDetail).Height = iNavSubH
sFrmLaunch.Refresh


Set sSubForm = ReturnCustomNavSubForm(sFormName)
If Not sSubForm Is Nothing Then
sSubForm.InsideHeight = LHeight
End If
End If


Set sFrm = Nothing
Set sFrmLaunch = Nothing
Set sSubForm = Nothing

End Sub


'Private Sub Form_Resize()
'Dim fNav As Access.Form
'Dim cnt As Control
'Dim iNavSubH As Integer, iNavSubW As Integer
'Dim sName As String, sFrm As Access.Form
'Dim iMeFrm As Integer
'
'Set fNav = Forms!frmCustomNav.Form
'
'Set sFrm = Me.Parent
'sName = sFrm.Name
'iNavSubH = sFrm.Section(acDetail).Height
'iMeFrm = Me.WindowHeight
'Me.InsideHeight = iNavSubH
''Set cnt = fNav.fSubForm
''If TypeOf cnt Is SubForm Then
'' iNavSubH = cnt.Height
'' iNavSubW = cnt.Width
''End If
'''
''Set gSide = fNav.grpSideMenu
''igrpSideMenuH = gSide.Height
''igrpSideMenuW = gSide.Width
''
''Set gTop = fNav.grpTopMenu
''igrpTopMenuH = gTop.Height
''igrpTopMenuW = gTop.Width
'''
''iNavBarH = fNav.navHeader.Height
''iNavFrmDetailH = fNav.Section(acDetail).Height
'
'End Sub
 
I can't tell from your image. Are you ending up having scroll bars, and you don't want any?
 
Please use code tags for that amount of code. :(
It keeps indentation (which I hope you are using) and makes it easier to read.
 
thedbguy, I will tackle the scrollbars once I get the sizing figured out. What I have noticed is that continuous forms will completely fill the subform control whereas, a regular form doesn't. None of the forms have any sizing in them.

Sorry about not using code tags.
ContRegExample.jpg
 
"continuous form, it will stretch to completely fill the subform control"

I do not observe this behavior in my form. I do not understand why you need to resize forms. This is why forms have scroll bars.

Data shown in "Category Summary" image is not normalized. Is this actually how data is stored in table or this is a CROSSTAB query?

You could provide your db for analysis.
 
Last edited:
"continuous form, it will stretch to completely fill the subform control"

I do not observe this behavior in my form. I do not understand why you need to resize forms. This is why forms have scroll bars.

Data shown in "Category Summary" image is not normalized. Is this actually how data is stored in table or this is a CROSSTAB query?

You could provide your db for analysis.
The data is normalized and yes it is crosstab query. I have made my own navigation form and use the subform control to switch forms in an out. Forms that are solely continuous forms display correctly, it's just regular forms do not. I'm still messing with this sizing and might be getting closer.
 
You need to build the form to the dimensions supported by the window in which you want to display it. Change the font sizes, get rid of that ribbon to the left. Leave the ribbon and make the details a popup.
 

Users who are viewing this thread

Back
Top Bottom