Results 1 to 14 of 14
  1. #1
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,191

    Event Procedure Doing Nothing

    Hi Guy's this is so bugging me why there is no action whatsoever on click of a list box

    All criterias meet, also i have put messages in to check through the stages but nothing at all happens ?

    I also am experiencing something i haven't before which is when you type something like Me.txtPODFile (because it's listed it should auto pick up while typing) i get to me.txtP then the listing disappears and the cursor jumps back 1 character or even using space bar, jumps back one space!!!! ??

    This only happens on this form



    Code:
    Dim DelDate As Date, fPath As String, fName As String
    
    
    
    Me.txtPODDate = Format(Me.lstDeliveries.Column(8), "dd-mm-yy")
    Me.txtPOMonth = Format(Me.lstDeliveries.Column(8), "mmm")
    Me.txtPOYear = Format(Me.lstDeliveries.Column(8), "yyyy")
    Me.txtCust = Me.lstDeliveries.Column(9)
    Me.txtDelTo = Me.lstDeliveries.Column(0)
    
    
    If Left(Me.txtCust, 2) = "Left 2 Chars Of Customer Removed Here" Then
    If Me.tbxPODOpen = True Then
    MsgBox ("Open Is True,Email Is False")
    fPath = "T:\Customer Removed Here\PDF\POD's\" & Me.lstDeliveries.Column(0) & "\"
    fName = Format(Me.lstDeliveries.Column(8), "dd-mm-yy") & "-" & Me.lstDeliveries.Column(0) & ".pdf"
    Me.txtPODFile = fPath & fName
    MsgBox (Me.txtPODFile)
    If Me.tbxPODOpen = True Then
    If Len(Dir(fPath & fName, vbDirectory)) > 0 Then
    MsgBox ("File Exsits")
    Application.FollowHyperlink fPath & fName
    Else
    MsgBox ("POD Doesn't Exist"), vbInformation + vbOKOnly, "FILE DOESN'T EXIST"
    End If
    End If
    End If
    End If

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,412
    I'm tired of trying to understand your loops without indenting, so not even going to try.

  3. #3
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,191
    Hi Ajax, I looked at your last suggestion on my previous post, went to the link but i'm 100% sure on the indenting, i am assuming you mean like the following ?

    Code:
    Dim DelDate As Date, fPath As String, fName As String
    
    
    
    Me.txtPODDate = Format(Me.lstDeliveries.Column(8), "dd-mm-yy")
    Me.txtPOMonth = Format(Me.lstDeliveries.Column(8), "mmm")
    Me.txtPOYear = Format(Me.lstDeliveries.Column(8), "yyyy")
    Me.txtCust = Me.lstDeliveries.Column(9)
    Me.txtDelTo = Me.lstDeliveries.Column(0)
    
    
    If Left(Me.txtCust, 2) = "TK" Then
        If Me.tbxPODOpen = True Then
        MsgBox ("Open Is True,Email Is False")
        fPath = "T:\Customer Name Removed\PDF\POD's\" & Me.lstDeliveries.Column(0) & "\"
        fName = Format(Me.lstDeliveries.Column(8), "dd-mm-yy") & "-" & Me.lstDeliveries.Column(0) & ".pdf"
        Me.txtPODFile = fPath & fName
        MsgBox (Me.txtPODFile)
            If Me.tbxPODOpen = True Then
            If Len(Dir(fPath & fName, vbDirectory)) > 0 Then
            MsgBox ("File Exsits")
            Application.FollowHyperlink fPath & fName
            Else
            MsgBox ("POD Doesn't Exist"), vbInformation + vbOKOnly, "FILE DOESN'T EXIST"
            End If
            End If
        End If
    End If

  4. #4
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    Better but more like this;

    Code:
     Me.txtPODDate = Format(Me.lstDeliveries.Column(8), "dd-mm-yy")
        Me.txtPOMonth = Format(Me.lstDeliveries.Column(8), "mmm")
        Me.txtPOYear = Format(Me.lstDeliveries.Column(8), "yyyy")
        Me.txtCust = Me.lstDeliveries.Column(9)
        Me.txtDelTo = Me.lstDeliveries.Column(0)
    
    
    
    
        If Left(Me.txtCust, 2) = "TK" Then
            If Me.tbxPODOpen = True Then
                MsgBox ("Open Is True,Email Is False")
                fPath = "T:\Customer Name Removed\PDF\POD's\" & Me.lstDeliveries.Column(0) & "\"
                fName = Format(Me.lstDeliveries.Column(8), "dd-mm-yy") & "-" & Me.lstDeliveries.Column(0) & ".pdf"
                Me.txtPODFile = fPath & fName
                MsgBox (Me.txtPODFile)
                If Me.tbxPODOpen = True Then
                    If Len(Dir(fPath & fName, vbDirectory)) > 0 Then
                        MsgBox ("File Exsits")
                        Application.FollowHyperlink fPath & fName
                    Else
                        MsgBox ("POD Doesn't Exist"), vbInformation + vbOKOnly, "FILE DOESN'T EXIST"
                    End If
                End If
            End If
        End If
    Can you see how much easier it is to follow the in's and outs of the IF Then Constructs?
    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
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    I normally use the double click event on a listbox as single clicking selects an item or use a button of the list to do something with the selected item(s).
    On your form do you have a timer event running, or on another open form, that causes issues in the editor sometimes.
    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 ↓↓

  6. #6
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,651
    Dave,

    I've suggested the Smart Indenter add-on in the past and you should really give it a try.
    It's free.
    It works with all versions.
    It makes writing and reading code simple.

    Once installed, you can just right click within a procedure and select Indent Procedure, Indent Module, or Indent Project. The add-on will then automatically do all the indenting.
    You will find it makes writing code easier and it makes it much easier to spot mistakes.

    I've used it for years and wouldn't do without it. Another good option which isn't free is MZ Tools which does indenting and a lot more.

    http://www.oaltd.co.uk/indenter/default.htm

    https://www.mztools.com/
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  7. #7
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,191
    Thank you guy's will make some adaptions as all of your suggestions, If i am stuck, As Ajax mentioned, i don't want to make things difficult and give this a try

    Do you just download it and install it ?

    Kind Regards

    Dave

  8. #8
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,191
    I have downloaded and installed VB6 version from suggestion, i am trying to find the executable or does VB pick it up when typing ?

    Kindest

  9. #9
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,791
    Not knocking the use of any tools for indenting but will say I don't get the need for them. There is a vbe setting for indentation - I have mine set to 3. When you write

    If this or that Then
    Do this...
    There is a key on your keyboard that provides the indent quite nicely - it's called Tab. Use that once as in the above example, twice when you need another indent, and so on and you will get the number of spaces according to the setting. When that code gets pasted within code tags here, it's all good. DMTDave, surely what you presented here is not what you have in your editor?

    If you don't have a timer event running somewhere (good suggestion), then maybe your control is corrupt.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  10. #10
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,191
    Hi Micron, thank you, definite no timer events are set

    So it is a matter of when using If, Do, While, Else, Select etc, tab the event then back 1 tab to close off these constants ?

    So the Ifs, Else, Do, Select etc as Minty suggested ?

    I have never written that way but understand and will start

  11. #11
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    I generally indent as i go (tab control), but if I have cut and pasted some code around it can go awry, that's when MZ-Tools or any automatic indenter is worth a look at.

    I would suggest you post the entire click event, that looks as if it's missing something as @micron suggested.
    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 ↓↓

  12. #12
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,791
    Quote Originally Posted by DMT Dave View Post
    Hi Micron, thank you, definite no timer events are set

    So it is a matter of when using If, Do, While, Else, Select etc, tab the event then back 1 tab to close off these constants ?

    So the Ifs, Else, Do, Select etc as Minty suggested ?

    I have never written that way but understand and will start
    Exactly! When you hit Enter, you remain at the "tab stop" (think Word tabs) set in the previous line. I just hit backspace key and remove one tab level when closing a block. If I replace the spaces with "tab " I could explain it this way (tab is the key press; tab is what the editor gives after Enter):

    If Not (rs.BOF And rs.EOF) Then (it's a given that Enter moves to next line?)
    tab If This Then
    tab tab Do This < Enter will place the cursor under D in "Do This" but the following Else should be at the level of the prior IF - so <backspace after Enter
    tab Else backspace before typing to remove one tab
    tab tab Do That
    tab End If backspace before typing to remove one tab
    End If backspace before typing to remove tab

    Indenting should be done for every kind of code block (basically anything that is a logical decision that isn't on just one line). It's not just for the sake of any person reviewing code, it helps to ensure that each block has the required beginning and ending parts, especially when nesting blocks.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  13. #13
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,412
    for further clarity I tend to use linefeeds to further separate the tasks and plenty of comments

    Code:
    With rs
    
        while not .eof
    
           if !myfield="X" Then 'this record needs an action
            
                 'what action1 is intended to do
                 action1
    
                 'what action2 is intended to do
                  action2a
                  action2b
    
            else 'what to do if <> X
           
                   'perhaps a comment here
                   action3
    
            end if
      
           .movenext
    
        wend
    
    end with
    when developing then by initially combining program flow with the comments, you can construct a framework of what you want to do on which you can then 'hang' the various actions

  14. #14
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,191
    Hi Ajax, thank you, will come back to it at some point, i am going to mark it solved even though it isn't quite working, i have refreshed another lists which list the files in the given folder for now and that click to open works ok on that list, for some reason, the initial list of table data to get the file name does nothing at all!

    I have had a tragic event in the family so I will mark solved and leave alone for now until I am able to come back to it

    But thank you to you all for helping

    Appreciated

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

Similar Threads

  1. Replies: 1
    Last Post: 09-27-2019, 10:58 AM
  2. Event procedure
    By vugar in forum Access
    Replies: 3
    Last Post: 09-09-2014, 11:36 PM
  3. Form Event Procedure
    By Jgk in forum Forms
    Replies: 7
    Last Post: 03-30-2014, 04:31 PM
  4. Replies: 1
    Last Post: 03-29-2014, 07:46 PM
  5. Replies: 3
    Last Post: 05-07-2012, 12:17 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