Code Examples For RunCommand Constants

Best Fit

acCmdSizeToFit

This code will only work from a toolbar. Add the following code to a module. Now add a button to a toolbar and set its action to =SizeFit().

'***************** Code Start *******************
' Code by Terry Wickenden

Function SizeFit()

  On Error GoTo ErrSizeFit

  DoCmd.RunCommand acCmdSizeToFit
  Exit Function

ErrSizeFit:

  Select Case Err
    Case 2046
      'Command not available
      MsgBox "Size to fit is not available at this time." & _
        vbCrLf & "Please ensure that you have selected a control.", _
        vbCritical, "Not Available"
    Case Else
      MsgBox Err.Number & ":-" & vbCrLf & Err.Description
  End Select

End Function
'****************** Code End ********************