Results 1 to 12 of 12
  1. #1
    Join Date
    Feb 2025
    Posts
    9

    Coordinates Χ, Υ

    Good evening


    I would like the BoxPos to move within the boundaries of the BoxPic with the mouse, and with a double click to be able to save the position I choose.




    Also, when I reopen the form, I want the BoxPos to go to the position it was saved to.
    Attached Files Attached Files

  2. #2
    jojowhite's Avatar
    jojowhite is offline Competent Performer
    Windows 11 Access 2021
    Join Date
    Jan 2025
    Posts
    433
    here try this.
    Attached Files Attached Files

  3. #3
    Join Date
    Feb 2025
    Posts
    9
    Ευχαριστώ πολύ αλλά στον υπολογιστή μου δεν κάνει τίποτα
    Χρειάζεται να κάνω κάτι;

  4. #4
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,930
    translation:

    Thank you very much, but it's not doing anything on my computer. Do I need to do anything?

  5. #5
    jojowhite's Avatar
    jojowhite is offline Competent Performer
    Windows 11 Access 2021
    Join Date
    Jan 2025
    Posts
    433
    You need to Click and Drag the BoxPos (Red marker) around the form.

    Πρέπει να κάνετε κλικ και να σύρετε το BoxPos (κόκκινος δείκτης) γύρω από τη φόρμα.

  6. #6
    Join Date
    Feb 2025
    Posts
    9
    Good evening
    I modified the code a little and managed to move the red dot.
    I found that the Red dot can only move right and down,
    it would be easy if the red dot could move in different directions, (i.e. Up – Down – Right – Left – Diagonal) I hope I didn't get too tired.
    Thanks



    Private Sub BoxPos_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
    Dim dX As Single, dY As Single

    ' If m_Moving Then
    dX = x - pX
    dY = y - pY
    With Me.BoxPos
    If .Left + dX >= m_LimitL And .Left + .Width + dX <= m_LimitR Then
    Me!Posx = Me.BoxPos.Left + dX
    End If
    If .Top + dY >= m_LimitT And .Top + .Height + dY <= m_LimitB Then
    Me!PosY = Me.BoxPos.Top + dY
    End If
    End With
    Me.Dirty = False

    With Me.BoxPos
    .Top = Me!PosY
    .Left = Me!Posx
    End With
    ' End If
    End Sub

  7. #7
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,555
    Please post code within code tags. Use the # button.
    It keeps indentation then, which I hope you are using?
    I would have thought the red dot can go whether it is allowed to within the constrains of the code?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  8. #8
    jojowhite's Avatar
    jojowhite is offline Competent Performer
    Windows 11 Access 2021
    Join Date
    Jan 2025
    Posts
    433
    it was fine moving left, right, top, bottom or diagonal
    and I don't see any problem. When you close and re-open
    the form, it the "red box" stays where you left it when
    you last closed the form.

  9. #9
    Join Date
    Feb 2025
    Posts
    9
    Καλησπέρα
    Τροποποίησα λίγο τον κωδικό και κατάφερα να μετακινήσω την κόκκινη κουκκίδα.
    Ανακάλυψα ότι η κόκκινη κουκκίδα μπορεί να κινηθεί μόνο δεξιά και κάτω,
    θα ήταν εύκολο αν η κόκκινη κουκκίδα μπορούσε να κινηθεί προς διαφορετικές κατευθύνσεις, (π.χ. Πάνω – Κάτω – Δεξιά – Αριστερά – Διαγώνια)
    Ελπίζω να μην σας κούρασα πολύ.
    Ευχαριστώ

    Code:
    Private Sub BoxPos_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
        Dim dX As Single, dY As Single
        
    '    If m_Moving Then
            dX = x - pX
            dY = y - pY
            With Me.BoxPos
                If .Left + dX >= m_LimitL And .Left + .Width + dX <= m_LimitR Then
                    Me!Posx = Me.BoxPos.Left + dX
                End If
                If .Top + dY >= m_LimitT And .Top + .Height + dY <= m_LimitB Then
                    Me!PosY = Me.BoxPos.Top + dY
                End If
            End With
            Me.Dirty = False
            
            With Me.BoxPos
                .Top = Me!PosY
                .Left = Me!Posx
            End With
    '    End If
    End Sub

  10. #10
    Join Date
    Feb 2025
    Posts
    9
    Ναι μένει εκεί που το άφησα
    αλλά στον υπολογιστή μου κινείστε μόνο δεξιά και κάτω

  11. #11
    isladogs's Avatar
    isladogs is offline Access MVP / VIP
    Windows 10 Office 365
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,204
    It works perfectly for me

    У меня это работает идеально.
    Colin Riddington, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I know I don't know, I keep quiet!

  12. #12
    Join Date
    Feb 2025
    Posts
    9
    Σας ευχαριστώ

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

Similar Threads

  1. Replies: 1
    Last Post: 05-19-2015, 01:59 AM
  2. Passing form Left and Top positioning coordinates
    By GraeagleBill in forum Programming
    Replies: 7
    Last Post: 11-18-2013, 08:12 AM
  3. Replies: 1
    Last Post: 11-12-2013, 10:37 AM
  4. GPS coordinates mapping on google map
    By engr_saud1 in forum Forms
    Replies: 1
    Last Post: 05-29-2013, 05:41 AM
  5. Replies: 1
    Last Post: 03-28-2013, 07:21 PM

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