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

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?
SteveL13Asked:
Who is Participating?
 
GozrehCommented:
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

0
 
GozrehCommented:
Is this question answered ? please close it  
or let us see what we can help
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.