none
is there a quick way to enter date and time in a memo field RRS feed

  • Question

  • I changed a memofield to be able to use formatting but since then I am not able to use the ctl-; and ctl-: to enter date and time anymore, functions that I use very often. Does anybody know how I can solve this f.e. with a macro or VBA or something else?

    Thanks, Sandra

    Saturday, June 14, 2014 7:50 AM

All replies

  • Sandra,

    With this code in the module of your form you will enter Date and Time in the control txtMemo with the shortcuts Alt+Shift+D and Alt+Shift+T (more or less likke you can do in Word).

    (I answered your question also in the dutch Access forum)

    Private Sub txtMemo_KeyDown(KeyCode As Integer, Shift As Integer)
        Dim acCtrl As Boolean
        Dim acShift As Boolean
        Dim acAlt As Boolean
        Dim lngStart As Long
        acCtrl = Shift And acCtrlMask
        acShift = Shift And acShiftMask
        acAlt = Shift And acAltMask
        lngStart = Me.txtMemo.SelStart
        If KeyCode = vbKeyD And acAlt And acShift Then
            DoCmd.CancelEvent
            Me.txtMemo.SelText = Format(Date, "dddd dd-mm-yyyy")
            Me.txtMemo.SelStart = lngStart + Len(Format(Date, "dddd dd-mm-yyyy"))
        End If
        If KeyCode = vbKeyT And acAlt And acShift Then
            DoCmd.CancelEvent
            Me.txtMemo.SelText = Format(Time, "hh:nn:ss")
            Me.txtMemo.SelStart = lngStart + Len(Format(Time, "hh:nn:ss"))
        End If
    End Sub

    

    Jan

    Saturday, June 14, 2014 3:05 PM