Results 1 to 13 of 13
  1. #1
    ksor's Avatar
    ksor is offline Competent Performer
    Windows 10 Access 2010 32bit
    Join Date
    Feb 2017
    Posts
    126

    Double click event NOT firing in a continous form ??

    I'm using Office 365 Home version.

    In most of my continous forms I have a field with a file name in it. The content of the file and why I have such a file name is not importent to this problem.

    When I double click the field the file name in that field is used to open the file in Word, Excel ect, ect. - and it works nicely - EVEN if focus is on one record and I double click the field on ANOTHER record.

    I now have 1 form where it seems NOT to work in that latter situation:

    If focus is on ONE record and I double click the field on ANOTHER record - the file does NOT open - focus just moves to that record !

    I have to single click to select the other record and THEN double click - then it works !!!!!!!

    The ONLY difference I can see is that it WORKS when the continous form in in a SUBform and will NOT work when the continous form is not in a subform !

    I don't think that's "by design" so what do I do wrong here ?



    Unfortunately the DB is way too big to share !

    The is nothing special to decode in the events, I think ...

    The problem could be rephrased, I think - why does a double click event ONLY fire in a textbox in a continous form when the record is in focus ?

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    what is the code behind the Dbl-click event?
    what is the contents of the failed textbox?
    is it a hyperlink or just text?

  3. #3
    Minty is offline VIP
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    why does a double click event ONLY fire in a textbox in a continuous form when the record is in focus ?
    Having just done some testing on both some subforms, and a straightforward continuous form, I can't replicate this behavior.
    That would indicate something else is happening, so what other events are set to trigger in that detail / form?
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  4. #4
    Minty is offline VIP
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  5. #5
    ksor's Avatar
    ksor is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2017
    Posts
    126
    and ......

  6. #6
    Minty is offline VIP
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  7. #7
    ksor's Avatar
    ksor is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2017
    Posts
    126
    Quote Originally Posted by Minty View Post
    Having just done some testing on both some subforms, and a straightforward continuous form, I can't replicate this behavior.
    That would indicate something else is happening, so what other events are set to trigger in that detail / form?
    I think the PROBLEM is in the continous form NOT in the sub forms and here is the ONLY two events I have in the main form where the problem actually is:

    Code:
    Private Sub Sti_til_fil_KeyDown(KeyCode As Integer, Shift As Integer)
        Select Case KeyCode
            Case vbKeyReturn
                If Me.ActiveControl = Me.Sti_til_fil Then
                    Sti_til_fil_DblClick Cancel
                Else
                End If
        End Select
    End Sub
    
    Private Sub Sti_til_fil_DblClick(Cancel As Integer)
       If Not ErAngivet(Me.Sti_til_fil) Then
         If Not ErAngivet(Me.Benævnelse) Then
            FejlMeld ("Der skal angives BÅDE benævnelse OG notat !")
            Me.Benævnelse.SetFocus
            Cancel = True
         Else
            Me.Sti_til_fil.Locked = False
            Me.Sti_til_fil.Text = "Notat-" & NotatID.Value & ".docx"
            Me.Sti_til_fil.Locked = True
            Set WRDobj = CreateObject("Word.Application")
    '        WRDobj.Visible = False
            Set doc = WRDobj.Documents.add
            doc.Sections(1).Headers(wdHeaderFooterPrimary).Range.Text = "NotatID: " & Me.NotatID.Value & "-" & Me.Benævnelse.Value
            doc.SaveAs TrimFrom("Right", CurrentDb.Name, "\") & "NOTAT_docs\" & Me.Sti_til_fil.Text, wdFormatDocumentDefault
            WRDobj.Quit
            Set doc = Nothing
            Set WRDobj = Nothing
            OpenNativeApp TrimFrom("Right", CurrentDb.Name, "\") & "NOTAT_docs\" & Me.Sti_til_fil
         End If
       Else
         OpenNativeApp TrimFrom("Right", CurrentDb.Name, "\") & "NOTAT_docs\" & Me.Sti_til_fil
       End If
    End Sub
    Notice that a break point at these two subs will NOT stop the execution (ofcause not in the keydown event because I use the mouse !)

    In ALL my other continous sub forms the execution STOPS at a break point at the double click event sub ... I think that prooves it has nothing to do with the code in the event sub - right ?

    Please DO REMEMBER what the problem is ... double clicking in the textbox at a record WITHOUT focus !
    (if I double click in the textbox at the record in focus ALL works nicely !)

    The content of the textbox is just plain text ... just happened to be a file name.

  8. #8
    Minty is offline VIP
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    From what you are saying then, the double click event is not being fired, as far as I can see the only thing that would cancel that is the Keydown code.
    Comment it out and see if your problem goes away.

    I'm actually puzzled by the keydown codes purpose?
    By definition the control will be the active control if you are checking in it's own keydown event?
    Or am I misreading things?
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  9. #9
    ksor's Avatar
    ksor is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2017
    Posts
    126
    Quote Originally Posted by Minty View Post
    From what you are saying then, the double click event is not being fired, as far as I can see the only thing that would cancel that is the Keydown code.
    Comment it out and see if your problem goes away.

    I'm actually puzzled by the keydown codes purpose?
    By definition the control will be the active control if you are checking in it's own keydown event?
    Or am I misreading things?
    The Keydown event is needed for users using the keyboard - so I can't just leave that out ...
    but of cause I tried leaving it out for the test here, and it makes NO difference - still no double click event fired !

    The two event subs I showed is for THE TEXTBOX itself !

    The FORM has its own set of event subs but NOT for double click !

  10. #10
    Minty is offline VIP
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    So show us the other form events, Current would be the obvious candidate. Any Detail section events?
    They could all fire before your text control event if you aren't on that record before hand.

    And please STOP shouting. I'm capable of reading your comments, and you haven't explained the logic of the code behind the keydown code, in plain English (and I appreciate that is not your native language) it reads to me as;

    I'm on control A
    Whilst on control A there is a keydown event
    If that key press is return then
    If the active control is control A ? (It must be, look at the event its attached to ?) then cancel the double click event??? What double click event???


    So what is this achieving?

    Code:
    Private Sub Sti_til_fil_KeyDown(KeyCode As Integer, Shift As Integer)
        Select Case KeyCode
            Case vbKeyReturn
                If Me.ActiveControl = Me.Sti_til_fil Then
                    Sti_til_fil_DblClick Cancel
                Else
                End If
        End Select
    End Sub
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  11. #11
    ksor's Avatar
    ksor is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2017
    Posts
    126
    Quote Originally Posted by Minty View Post
    So show us the other form events, Current would be the obvious candidate. Any Detail section events?
    They could all fire before your text control event if you aren't on that record before hand.

    And please STOP shouting. I'm capable of reading your comments, and you haven't explained the logic of the code behind the keydown code, in plain English (and I appreciate that is not your native language) it reads to me as;

    I'm on control A
    Whilst on control A there is a keydown event
    If that key press is return then
    If the active control is control A ? (It must be, look at the event its attached to ?) then cancel the double click event??? What double click event???


    So what is this achieving?

    Code:
    Private Sub Sti_til_fil_KeyDown(KeyCode As Integer, Shift As Integer)
        Select Case KeyCode
            Case vbKeyReturn
                If Me.ActiveControl = Me.Sti_til_fil Then
                    Sti_til_fil_DblClick Cancel
                Else
                End If
        End Select
    End Sub
    You're focusing om so many other things that has nothing to do with the problem - the more code you see, the more explanation you want and the keydown is NOT part of the problem here !

    As I told I my last posting it's for users using the keyboard and if they do press Return it just starts the code in the Double click event - and it works nicely !
    Maybe I copied it from somewhere else where more controls were involved and maybe it could be minimized a little more - I don't remember and it's completely irrelevant !

    Here are event subs on FORM level - but nothing special here, I think :

    Code:
    Private Sub Form_Current()
        Me.txtHLId = NotatID
        Me.Sti_til_fil.SetFocus
        evtTilføjelser
    End Sub
    
    Private Sub evtTilføjelser()
        ' Notes can ONLY be added when
        ' specific type of notes are choosed
        Me.AllowAdditions = Not Me.chkType.OldValue
    End Sub
    
    Private Sub Form_Load()
        chkType.Value = True
        Me.Requery
    End Sub
    
    Private Sub Form_BeforeUpdate(Cancel As Integer)
        If Not ErAngivet(Me.Benævnelse) Or Not ErAngivet(Me.Sti_til_fil) Then
            FejlMeld ("Der skal angives BÅDE en benævnelse OG et notat !" & CrLf(1) & _
                      "Tryk evt. ESC for at få den gamle værdi tilbage !" & CrLf(2) & _
                      "Ellers skal HELE notatet slettes ved at klikke på " & CrLf(1) & _
                      "bjælken i venstre side af formularen og DELETE !")
        End If
    End Sub
    
    Private Sub Form_BeforeInsert(Cancel As Integer)
       Me.NotatTypeID = Me.cboNotatType.Column(0)
    End Sub
    
    Private Sub Form_Delete(Cancel As Integer)
        If Veto("Skal notatet overføres til mappen 'SLET_docs' ?", vbDefaultButton1) = vbYes Then
            flytFilTilSlet "NOTAT_docs\", Me.Sti_til_fil
        End If
    End Sub
    
    Private Sub Form_Open(Cancel As Integer)
        Call gfncCenterForm(Me)
        cboNotatType = cboNotatType.ItemData(0)
    End Sub
    Remember though even if a break point is inserted in both these event subs excecution is NOT stopped when performing af double click in the textbox on a record NOT in focus.
    Execution IS stopped if you double click in the textbox on the focused record !

  12. #12
    Minty is offline VIP
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    I suspect - and I haven't tested, but comment out the line in red ;

    Code:
    Private Sub Form_Current()
        Me.txtHLId = NotatID
        Me.Sti_til_fil.SetFocus
        evtTilføjelser
    End Sub
    I believe this will fire before your double click event, and is probably confusing it.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  13. #13
    ksor's Avatar
    ksor is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2017
    Posts
    126
    SOLVED !

    Code:
    Private Sub Form_Current()
        Me.txtHLId = NotatID
    '    Me.Sti_til_fil.SetFocus
        evtTilføjelser
    End Sub
    commenting out the Setfocus solves the problem !

    thx for you time !

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

Similar Threads

  1. Replies: 7
    Last Post: 03-11-2017, 11:00 AM
  2. Combo box On Dbl-Click event not firing
    By GraeagleBill in forum Forms
    Replies: 5
    Last Post: 12-26-2016, 06:45 PM
  3. Opening records via Double-Click event on a search form.
    By IncidentalProgrammer in forum Programming
    Replies: 4
    Last Post: 11-21-2014, 03:47 PM
  4. Replies: 3
    Last Post: 08-21-2014, 07:42 PM
  5. tab control - firing a page on-click event
    By Chuck55 in forum Programming
    Replies: 7
    Last Post: 05-01-2012, 09:57 AM

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