We help IT Professionals succeed at work.

How make sub-form appear in the middle of the screen

SteveL13 asked
I have a sub-form which is in the upper-right hand corner of the main form.  And I have a command button on the main form which is resizing the sub-form when it is clicked with this code:

Me.subfrmTeamsCoachesByDivisionDS.Width = 18000

But I also want the sub-form to appear in the middle of the screen when the command button is clicked.

Is this possible?
Watch Question

Software Developer
Yes, you can use this code
   Dim intOrigWidth As Integer    ' Original form width
   Dim intOffSet As Integer       ' Distance to move the control
   intOrigWidth = frm.Width
   intOffSet = (frm.WindowWidth - intOrigWidth) / 2
   frm.Painting = False           '-- Freeze the screen to prevent flickering
   subfrmTeamsCoachesByDivisionDS.left = subfrmTeamsCoachesByDivisionDS.left + intOffSet
   frm.Painting = True

Open in new window

GozrehSoftware Developer

Is this question answered ? please close it  
or let us see what we can help