Results 1 to 10 of 10
  1. #1
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919

    How to suppress "Right-Click" action on a text box

    I need to allow right-click in Record Selector column on a continuous form to allow deletion of a record, BUT NOT on the contents of a text box within the record. I don't see any text box property where that can be controlled. While the user needs to be able to "Cut" the record, a right-click in the wrong spot could potentially inadvertently clear a record field, so I'm just trying to avoid that.
    Bill

  2. #2
    jwhite is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Dec 2012
    Location
    North Carolina
    Posts
    349
    You can use the MouseUp event on the textbox:
    Code:
    Private Sub Text0_MouseUp(Button As Integer, Shift As Integer, _
    X As Single, Y As Single)
    If Button = acRightButton Then
    MsgBox "You pressed the right button."
    End If
    End Sub

    Have it for each text box or have the MouseDown event call a common function.


  3. #3
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    The event fires as expected but that doesn't suppress the right-click popup menu.

  4. #4
    jwhite is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Dec 2012
    Location
    North Carolina
    Posts
    349
    Was hoping you would check out something like: https://msdn.microsoft.com/en-us/lib.../ff836964.aspx

  5. #5
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Here you are - how to cancel right-click for a control.

    Use the Mouse-up event, and it's one line of code:

    Code:
    Private Sub Main_Description_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
      If Button = 2 Then DoCmd.CancelEvent
    End Sub
    Button = 2 is right-click.

  6. #6
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    Thinking you intended I add the CancelEvent, I tried this code:
    Code:
    If Button = acRightButton Then
    DoCmd.CancelEvent
    MsgBox "You pressed the right button."
    End If
    But the right-click popup continues to display

  7. #7
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    The docmd.CancelEvent has to be in the MouseUP event, not the MouseDown event.

  8. #8
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    Right you are!
    Code:
    Private Sub tbAcctName_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    '*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
    ' Trap and suppress any potential occurrences of a right-click pop-up menu, lest the
    ' account name field get inadvertently left blank.
    '*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
        If Button = acRightButton Then DoCmd.CancelEvent
    End Sub
    Thanks,
    Bill

  9. #9
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,412
    if you want to prevent any shortcut menus appearing set the form shortcut menu property (on other tab) to no

  10. #10
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    Yes, I'm aware of that. But, the problem to be solved had to do with text boxes within the displayed records BUT NOT suppressing the form's properties.
    Thanks for your thoughts,
    BIll

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

Similar Threads

  1. Replies: 6
    Last Post: 11-21-2015, 09:52 AM
  2. Replies: 2
    Last Post: 07-31-2015, 02:49 PM
  3. Suppress "Error" message following "Cancel = True"
    By GraeagleBill in forum Programming
    Replies: 7
    Last Post: 03-23-2014, 05:40 PM
  4. Export "Query or Report" to a "Delimited Text File"
    By hawzmolly in forum Import/Export Data
    Replies: 3
    Last Post: 08-31-2012, 08:00 AM
  5. Replies: 3
    Last Post: 11-15-2011, 02:41 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