We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now

x

Position popup relative to a command button.

ramrom
ramrom asked
on
Medium Priority
588 Views
Last Modified: 2008-02-01
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?
Comment
Watch Question

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

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
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.
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.
ramromconsultant

Author

Commented:
Well ignore that. I found the right way to refer to the subform. It works.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.