Page 1 of 2 12 LastLast
Results 1 to 15 of 21
  1. #1
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    1,919

    "Y" position of a text box control on a continuous form

    How does one obtain in code the "Y" position of a text box control on a continuous form. The "X" is basically a constant for all records being displayed at any given time, but the "Y" of a given text box varies as the records are scrolled.

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    The position of the control is relative to the detail section. The detail section is repeated.

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Not sure what you're trying to achieve, but perhaps it's something this will solve?

    http://www.lebans.com/SelectRow.htm

    I've used it where I needed to requery a continuous form and the users wanted the form to return where it was. Normally I'd just bookmark the record, but they wanted it so that it would return to the same position on the screen as well.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    1,919
    That is correct. Now you appreciate the question

    Paul has chimed in with a suggestion, I'll look at that a bit later this afternoon.

  5. #5
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    1,919
    Paul,
    I want to position a popup form in close proximity to a text box that has been clicked. I can't even find the "Y" coordinate of the record that contains the detected text box.

  6. #6
    Micron is online now Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,788
    Quote Originally Posted by GraeagleBill View Post
    Paul,
    I want to position a popup form in close proximity to a text box that has been clicked. I can't even find the "Y" coordinate of the record that contains the detected text box.
    Assuming the textbox is in the detail section and not on the header/footer, perhaps it would be easier and close enough if you got the x / y coordinates of the mouse click?
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  7. #7
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    1,919
    PERFECT. Somehow, I had it on the brain that a mouse-down event wouldn't necessarily be associated with the control of interest, but rather the form itself.

  8. #8
    Micron is online now Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,788
    The MouseDown event, for example, applies to forms, form sections and controls on a form (not a report) and all mouse events that occur are relative to that object. I suppose you could get the x and y coordinates of the top and left of the control, but don't know what you'd get for the vertical position on a continuous form. Using the API call to get the coordinates is with respect to the application window, I believe. Both methods may not suit your purpose. I also think either answer will be in twips, which you might have to convert if you want to open a popup form at the mouse position.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  9. #9
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    1,919
    Getting the x,y relative to the app window works fine. And, since the x is constant within the detail section for any given control on a continuous form, I can fine tune the positioning of the popup in the horizontal if desired.

    And yes, the units are in twips. The only exception that I know of to that is the use of GetXCursorPos() and GetYCursorPos(), two function entry points in api apiGetWindowRect. The values returned there need to be converted to twips, (X 15).

    Thanks,
    Bill

  10. #10
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Good call, the mouse events. That was going to be my second thought. I use that in a db where users can move labels around on a "map" background to keep track of where taxis are. The x/y coordinates tell me what zone they're in, based on a table of grids.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  11. #11
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    1,919
    WOW! I thought I was "out of the woods" on this one. How is it that the x,y reported with the Mouse_Down event is 735,135 where I know that the x coordinate should be more like 7980 twips! (controlname.Left = 5.5417")

  12. #12
    Micron is online now Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,788
    Your numbers are relative to the top left of the control (or form if the mousedown is on the form), no?
    A conversion calculator I used gave me 7980.048 for 5.5147, so your click was probably 735,135 (twips) offset from the control top left.
    Last edited by Micron; 12-31-2015 at 03:06 PM. Reason: calculator
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  13. #13
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    1,919
    I've gone "full circle"! Namely, back to my original understanding in that the x,y of a mousedown on a control is the x,y relative to the control's upper left corner. So, on a continuous form, I can always come up with a fairly accurate x value but knowing where the current record is on the screen is somewhat of a "crap-shoot" using the api referenced earlier in this thread.

  14. #14
    Micron is online now Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,788
    How does one obtain in code the "Y" position of a text box control on a continuous form.
    but knowing where the current record is on the screen is somewhat of a "crap-shoot
    So I'm not sure how close you need to be. What about using the GetCursorPos API on the control's mousedown event? It will return the vertical position in twips relative to the window (I think, as opposed to the screen - not sure which), but at least it won't be relative to the control. I placed a vertical line over a control on a continuous form and tried to keep the left/right position as close to the line as possible. I see that it returns the vertical position while the left/right is fairly constant.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  15. #15
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    1,919
    I used the api:

    The only exception that I know of to that is the use of GetXCursorPos() and GetYCursorPos(), two function entry points in api apiGetWindowRect. The values returned there need to be converted to twips, (X 15).
    To obtain the "Y" coordinate in the click event. If I have any further problems, I'll pursue the use of the GetCursorPos API.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 09-07-2015, 08:00 AM
  2. Replies: 12
    Last Post: 01-28-2015, 02:37 PM
  3. Replies: 3
    Last Post: 06-06-2013, 08:22 AM
  4. Replies: 13
    Last Post: 01-11-2012, 09:44 PM
  5. Replies: 1
    Last Post: 10-19-2009, 02:37 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums