Return form and controls to default size

  • Thread starter Me.Frustrated = True
  • Start date
M

Me.Frustrated = True

I have a pair of functions that resize a form and all of its controls at the
click of a button. These are for one of my visually-impaired users who likes
his buttons, boxes, and text to be larger. One button resizes all the
controls up by a factor of 1.1, the other resizes them all down.

I also want to put in a button to return everything to their default sizes.
Could anyone please point me in the right direction to restore the default
sizes for all controls, the "Detail", "Header", and "Footer" sections of a
form? Thanks in advance.
 
J

John W. Vinson

I also want to put in a button to return everything to their default sizes.
Could anyone please point me in the right direction to restore the default
sizes for all controls, the "Detail", "Header", and "Footer" sections of a
form? Thanks in advance.

Constantly resizing controls and saving a form will rapidly bloat your
database. I'd really suggest using a Split Database (this is a good idea in
ANY case), with the forms, reports and code in a frontend linked to a shared
backend containing the tables; each user should have their own private copy of
the frontend. This would let you provide this user with a custom large-text
frontend, while other users have a smaller text version.
 
M

Me.Frustrated = True

Thanks for your reply John.

The database is split properly into FE/BE. Our operators share a desk that
has three workstation computers, and any of my 10 operators can log on to any
one of the three computers. Because the front ends are saved on each machine
rather than in each person's profile, I wanted to allow this user to
"magnify" the controls no matter which station he uses during his shift
without saving the new dimensions each time he clicks the button.

Even if he clicks the button several times to magnify the form and controls,
he can then close the form and re-open it and it will be back to normal (the
magnified dimensions are not saved.) I just wanted to use a button to
display the form at normal size without him having to close/reopen it.

I would gladly paste the code I have written if it would help illustrate
what I'm looking for.

Mike
 
J

John W. Vinson

Thanks for your reply John.

The database is split properly into FE/BE. Our operators share a desk that
has three workstation computers, and any of my 10 operators can log on to any
one of the three computers. Because the front ends are saved on each machine
rather than in each person's profile, I wanted to allow this user to
"magnify" the controls no matter which station he uses during his shift
without saving the new dimensions each time he clicks the button.

Even if he clicks the button several times to magnify the form and controls,
he can then close the form and re-open it and it will be back to normal (the
magnified dimensions are not saved.) I just wanted to use a button to
display the form at normal size without him having to close/reopen it.

I would gladly paste the code I have written if it would help illustrate
what I'm looking for.

That would probably help. The only way I can think of would be to store the
current magnification scale in a VBA variable so that you can "undo" it, or to
store the default dimensions similarly.
 
M

Me.Frustrated = True

Here is my code to "magnify." Apologies in advance, I'm not much of a
programmer and there's probably a much easier way to do this:

*** code start ***
Public Function ResizeUp()
On Error GoTo err_blocker

Dim strForm As Form
Dim ctl As Control
Set strForm = Screen.ActiveForm

With strForm
.Width = strForm.Width * 1.1
.Detail.Height = strForm.Detail.Height * 1.1
.FormHeader.Height = strForm.FormHeader.Height * 1.1
.FormFooter.Height = strForm.FormFooter.Height * 1.1
End With

RunCommand acCmdSizeToFitForm

For Each ctl In strForm.Controls
If ctl.ControlType = acTextBox Or ctl.ControlType = acComboBox _
Or ctl.ControlType = acLabel Or ctl.ControlType = acCommandButton Then
ctl.Height = ctl.Height * 1.1
ctl.Width = ctl.Width * 1.1
ctl.FontSize = ctl.FontSize * 1.1
ctl.Left = ctl.Left * 1.1
ctl.Top = ctl.Top * 1.1
End If
Next

exit_here:
Exit Function

err_blocker:
MsgBox (Err.Number & ", " & Err.Description)
Resume exit_here

End Function
*** code end ***

The ResizeUp() function is similar, just goes the other way (smaller.) I
just want to allow my operator to easily go back to the original settings.

Thanks John!
 
M

Me.Frustrated = True

I wrote the stuff below to try to restore the defaults. I also put code in
the OnClick event of both the "grow" and "shrink" buttons to count the number
of times the form was magnified or de-magnified (magnify adds 1, de-magnify
subtracts 1,) and store that count in the form's "Tag" property. Then I used
the Tag value (an integer) to create a "multiplier." In theory, dividing each
of the form's controls and dimensions by the formula (1.1 ^ mult) should take
them back to the original sizes, but it doesn't:

*** code start ***
Public Function DefaultSize()
Dim strForm As Form
Dim ctl As Control
Dim dflt As Double
Dim mult As Long
Set strForm = Screen.ActiveForm
mult = strForm.Tag
dflt = 1.1 ^ mult

'On Error GoTo err_blocker

Do While mult > 0
With strForm
.Width = strForm.Width / dflt
.Detail.Height = strForm.Detail.Height / dflt
.FormHeader.Height = strForm.FormHeader.Height / dflt
End With

For Each ctl In strForm.Controls
If ctl.Tag <> "NoResize" Then
If ctl.ControlType = acTextBox Or ctl.ControlType = acComboBox _
Or ctl.ControlType = acLabel Or ctl.ControlType =
acCommandButton Then
ctl.Height = ctl.Height / dflt
ctl.Width = ctl.Width / dflt
ctl.FontSize = ctl.FontSize / dflt
ctl.Left = ctl.Left / dflt
ctl.Top = ctl.Top / dflt
End If
End If
Next
Loop

RunCommand acCmdSizeToFitForm

exit_here:
Exit Function

err_blocker:
MsgBox (Err.Number & ", " & Err.Description)
Resume exit_here

End Function
*** code end ***
 

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