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

    Passing form Left and Top positioning coordinates

    I have a main form with a command button with a click event thus:



    Code:
    Private Sub cmdColors_Click()
    DoCmd.OpenForm "frmColorChart", acNormal, , , , , Me.cmdColors.Left & ";" & Me.cmdColors.Top
    End Sub
    The intent is to communicate to the form "frmColorChart" where on the screen to display the form, right on top of the command button. The code in the Open event of the form "frmColorChart" is:

    Code:
    Private Sub Form_Open(Cancel As Integer)
    Dim a() As Single
    a = Split(OpenArgs, ";")
    Me.Form.Left = a(0)
    Me.Form.Top = a(1)
    End Sub
    Where my intent is to parse OpenArgs into its two parts and set the left and top positioning of the form. As coded, I get a "type mismatch" on the Split function in the Form_Open. I've tried Dim'ing the array as variant but still get the error.

    Also, I tried to further experiment with setting Me.Form.Left with a literal value to see if I could effect positioning, but I get an error there as well having to do with Object legalities. With the latter experiment, it seems that the property Me.Form.Left might not be the correct expression to use?

    Any thoughts on how to clear this up?

    Thanks,
    Bill

  2. #2
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,016
    Top and Left are Properties of Controls; they don't apply to Forms. For Forms you need to use the DoCmd.MoveSize Method.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  3. #3
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    1,919
    Thanks, DoCmd.MoveSize did the job. Also had to Dim the array as string.
    Thanks again,
    Bill

  4. #4
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    1,919
    Linq,
    Where do I go to find out the screen coordinates of the main form I posted in my initial question. I'll need to add those values to that of the command control in order to position my popup form "frmColorChart".
    Thanks,
    Bill

  5. #5
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,016
    Me.WindowLeft & Me.WindowTop will give you that, in Twips.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  6. #6
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    1,919
    Got it! Strange that the value is negative for the left. "down from the top" makes sense, but negative left of zero does not.

    Thanks,
    Bill

  7. #7
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    1,919
    Linq,
    I'm still not getting my popup form positioning. The main form is wanting to pass the screen values of the command button so that the popup will position itself on top of the command button. I.e., The upper left corners of the popup and command button will be the same. The negative values didn't seem like what was needed, so I coded this way:

    Code:
    Private Sub cmdColors_Click()
    
    DoCmd.OpenForm "frmColorChart", acNormal, , , , , _
    Abs(Me.WindowLeft) + Me.cmdColors.Left & ";" & Abs(Me.WindowTop) + Me.cmdColors.Top
    
    End Sub
    What do I have wrong?

    Thanks,
    Bill

  8. #8
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    1,919
    Me.WindowLeft and Me.WindowTop are relative to the Access window, NOT the absolute screen coordinates. The values taken from Me.cmdColors.Left and Me.cmdColors.Top (my command control) when used with the DoCmd.MoveSize method are treated as absolute screen coordinates, which of course would cause the popup form to open at the same position on the screen no matter where the Access window is positioned on the screen. To be consistent, and unlike Me.WindowLeft and Me.WindowTop, I need a method that will give me the Left and Top coordinates of the Access Window. OR, how to set the Left and Top coordinates of the control relative to the Access window.
    Bill

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 11-12-2013, 10:37 AM
  2. GPS coordinates mapping on google map
    By engr_saud1 in forum Forms
    Replies: 1
    Last Post: 05-29-2013, 05:41 AM
  3. Replies: 3
    Last Post: 02-02-2011, 01:00 PM
  4. Help Needed Form Positioning
    By codybecker in forum Forms
    Replies: 3
    Last Post: 09-15-2010, 08:50 PM
  5. form positioning
    By taylorosso in forum Forms
    Replies: 5
    Last Post: 08-23-2009, 08:00 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