Ringhal
05-21-2015, 02:45 AM
Hi
I have been struggling with this for a few days now, and need some help. I've created an Access database and this is distributed throughout the company. Everybody uses different screen sizes and pixel resolutions and I wanted to create a short code the can resize the various forms and controls. Below is the code I used that works for some controls and forms, but not everything. After finding out that Visual Basic uses twips instead of centimeters (my default unit of measure), I converted these values where needed.
Here's what I have: A multipage form (or Tab Control) that has 5 pages with 1 subform per page (plus other buttons and boxes). Each of the subforms need to be the same size.
Sub Test()
'the default unit of measurement in Visual Basic is twips
'1 centimeter = 566.9291338583 twip
Dim i As Long
Dim CtrlForm, CtrlPage
For i = 2 To 6
Select Case i
Case 1
Set CtrlPage = Forms![frmForm A]![MultiPage A]
GoSub frmName_multipage
Case 2
Set CtrlForm = Forms![frmForm A]![subform A]
Case 3
Set CtrlForm = Forms![frmForm A]![subform B]
Case 4
Set CtrlForm = Forms![frmForm A]![subform C]
Case 4
Set CtrlForm = Forms![frmForm A]![subform D]
Case 5
Set CtrlForm = Forms![frmForm A]![subform E]
Case 6
Set CtrlForm = Forms![frmForm A]![subform F]
Case 2 To 6
GoSub frmName_subform
Case Else
Exit For
End Select
Next i
Exit Sub
frmName_subform:
With CtrlForm
.Left = 56 '0.10 cm
.Width = 10204 '18 cm
End With
Return
frmName_multipage:
With CtrlPage
.Left = 0 '0.00 cm
.Width = 13606 '24 cm
End With
Return
End Sub
I have been struggling with this for a few days now, and need some help. I've created an Access database and this is distributed throughout the company. Everybody uses different screen sizes and pixel resolutions and I wanted to create a short code the can resize the various forms and controls. Below is the code I used that works for some controls and forms, but not everything. After finding out that Visual Basic uses twips instead of centimeters (my default unit of measure), I converted these values where needed.
Here's what I have: A multipage form (or Tab Control) that has 5 pages with 1 subform per page (plus other buttons and boxes). Each of the subforms need to be the same size.
Sub Test()
'the default unit of measurement in Visual Basic is twips
'1 centimeter = 566.9291338583 twip
Dim i As Long
Dim CtrlForm, CtrlPage
For i = 2 To 6
Select Case i
Case 1
Set CtrlPage = Forms![frmForm A]![MultiPage A]
GoSub frmName_multipage
Case 2
Set CtrlForm = Forms![frmForm A]![subform A]
Case 3
Set CtrlForm = Forms![frmForm A]![subform B]
Case 4
Set CtrlForm = Forms![frmForm A]![subform C]
Case 4
Set CtrlForm = Forms![frmForm A]![subform D]
Case 5
Set CtrlForm = Forms![frmForm A]![subform E]
Case 6
Set CtrlForm = Forms![frmForm A]![subform F]
Case 2 To 6
GoSub frmName_subform
Case Else
Exit For
End Select
Next i
Exit Sub
frmName_subform:
With CtrlForm
.Left = 56 '0.10 cm
.Width = 10204 '18 cm
End With
Return
frmName_multipage:
With CtrlPage
.Left = 0 '0.00 cm
.Width = 13606 '24 cm
End With
Return
End Sub