Trying to catch click on record selector in datasheet-style subform

eellenoff

Registered User.
Local time
Today, 06:09
Joined
Jul 17, 2007
Messages
17
Hello,

I have a form with a subform in datasheet mode. I would like to perform an action when the user clicks on the row-selector/row-header column (see screenshot). I am currently using the form's onClick action, but that has the annoying property of getting triggered when I click on a column header to access the sort menu. Is there anyway to capture the click event only when it is on the row header? I also tried using onCurrent, but that gets fired several times as the form loads.

One bonus question: I want a different behavior for single click vs double click. It seems that a double click first calls the single click listener and then the double click listener, so right now my double click listener basically undoes the single click's action. Is there a better way to do this?

Thanks,
-Eric

Windows XP
Access 2007
 

Attachments

  • record_selector.PNG
    record_selector.PNG
    38 KB · Views: 761
Last edited:
Simulate the datasheet view using a continuous form. This is done by deleting the label controls and setting the others cheek to cheek. Place a set of labels in the header section.

Include a textbox to simulate the selector column and use its events.
 
In place of the form's click event, you can also use:
Code:
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Y >= 300 Then
        MsgBox "record selector clicked"
    End If
End Sub

For your second request, my advice would be to break down the set of routines into two parts and let your single click perform the first whilst the double click continues from where the single click left off. There's no way of boycotting this behaviour.
 
Also, you can selectively disable/enable current event handling with code like ...
Code:
Private Sub Form_Open(Cancel As Integer)
  Me.OnCurrent = ""
  Me.TimerInterval = 1000
End Sub

Private Sub Form_Timer()
  Me.TimerInterval = 0
  Me.OnCurrent = "[Event Procedure]"
End Sub
 
To differentiate between the Click a Double Click try this: -

Code:
Option Explicit
Option Compare Text


Private Declare Function apiGetDoubleClickTime Lib "user32" _
                     Alias "GetDoubleClickTime" () As Long


Private Sub Form_Timer()

    Me.TimerInterval = 0
    ServiceFormClick
    
End Sub


Private Sub Form_Click()

    Me.TimerInterval = apiGetDoubleClickTime() + 5

End Sub


Private Sub Form_DblClick(Cancel As Integer)

    Me.TimerInterval = 0
    MsgBox "Here to service the Form DoubleClick", , "Double Click"
    
End Sub


Private Sub ServiceFormClick()

    MsgBox "Here to service the Form Click", , "Click"

End Sub

Hope that helps.

Chris.
 
Quick note to anyone coming here 10 years later: you can assign a double-click handler to controls or the datasheet form itself. The current record will be set to the record on which the user double-clicked.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom