I am trying to open a form in dialog mode, and then resize it to a desired size using DoCmd.MoveSize from a module. Ideally I would like this all to run from said module.
Currently the form opens, but does not get resized. I am guessing this is either because the form is not yet active when the command is being run or because acDialog in the OpenForm command prevents it from being executed. I think I could get away with it plugging the MoveSize command into the OnlOad event of the form but I would prefer having as much of the functionality in the module instead. Is there some way around this issue? Like maybe there is some kind of method to wait for the form to be active or some way to plug a command into the OnLoad event from the module itself? As you can tell I am not too familiar with vba yet. It's part of a little project I am doing. Appreciate any help.
Some sample code is as follows:
This one does not resize the form:
Option Compare Database
Option Explicit
Public Function OpenFormDialog()
DoCmd.OpenForm "MsgBoxForm", acNormal, , , acFormAdd, acDialog
DoCmd.MoveSize , , , 9500
End Function
This one throws an error because the form is not found:
Option Compare Database
Option Explicit
Public Function OpenFormDialog()
DoCmd.OpenForm "MsgBoxForm", acNormal, , , acFormAdd, acDialog
Forms.("MsgBoxForm").DoCmd.MoveSize , , , 9500
End Function