eirikdaude
eirikdaude

Reputation: 3254

Detect click on textbox in form

I want a certain function to be run every time someone clicks on a textbox in my form. So far I have managed to detect when it gets focus and when it is doubleclicked, using the following two eventhandlers, but I am unsure about how to catch when it is clicked once while it already has focus.

Does anyone here have any experience with catching such an event? I don't seem to find any obvious suspects in the dropdown-menus of the VBA editor.

Private Sub tbxTil_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
    Me.tbxTil = format(oppdater_dato(CDate(Me.tbxTil)), "dd.mm.yy", vbMonday, vbFirstFourDays)
End Sub

Private Sub tbxTil_Enter()
    Me.tbxTil = format(oppdater_dato(CDate(Me.tbxTil)), "dd.mm.yy", vbMonday, vbFirstFourDays)
End Sub

Upvotes: 0

Views: 607

Answers (1)

Brian M Stafford
Brian M Stafford

Reputation: 8868

You can use the Mouse events, something like this:

Private Sub tbxTil_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
   MsgBox "Click"
End Sub

Upvotes: 1

Related Questions