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?
LVL 17
ramromconsultant Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

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.