Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 554
  • Last Modified:

Position popup relative to a command button.

I want to position a popup to the right of a subform.

I presume to use movesize, but that requires coordinates relative to the screen.

I activate the popup from a command button on the subform.

How do I get the top and left coordinates of the subform relative to the screen so I can use movesize?
0
ramrom
Asked:
ramrom
  • 3
1 Solution
 
Rick_RickardsCommented:
First you will need the Top and Left coordinates of the Parent form.  This requires the use of API calles but fortunately Microsoft supplies all the code needed to leverage these API calls in the following KB article.

http://support.microsoft.com/default.aspx?scid=kb;en-us;210141

Using the GetFormDimensions() Function detailed the in the above KB article above, you would then get the Top and Left position of the Sub form and add those values to the Top and Left Form position acquired from GetFormDimensions().

At this point you'll be armed with the location where you want the popup form to open up to but you'll need to pass that information to the form.  Typically this is done via the OpenArgs parameter.  You'll need a string parsing utility to extract the X and Y coordinates passed via the OpenArgs String.  If you don't have one the Access Developers Handbook (Published by SyBex) supplies a very good one expressly for this purpose.

When the Form Loads you would parse the OpenArgs string for the X and Y coordinates passed in the step above and then use the DoCmd.MoveSize method to reposition the form.

Although this process may seem very daunting at first once you're comfortable with the technique it's not so bad.  

Rick
0
 
ramromconsultant Author Commented:
"Although this process may seem very daunting" ... actually it does not.I've been doing stuff like this for years. I just needed the pointer to the right API, and the sample code worked just fine.

Rather than messing with openargs and string parsing, I gave my form a move subroutine which takes the coordinates, sets focus to self and does the movesize.
I then docmd.openform and follow that with a call to the move sub.
0
 
ramromconsultant Author Commented:
Oh Oh I just discovered that the above works fine if I feed GetFormDimensions() the main form, but I'm dealing with positioning the popup relative to a subform (actually a subform on a subform). I have not found a way to pass the subform to GetFormDimensions(). So I am back to square 1.
0
 
ramromconsultant Author Commented:
Well ignore that. I found the right way to refer to the subform. It works.
0

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now