Page 1 of 3 123 LastLast
Results 1 to 15 of 32
  1. #1
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664

    Program Progress will not stop at breakpoint

    In the attached zip file contains db that I believe is not working. I have put a breakpoint with the VBA code that goes with the form frmPersonnel.



    In other uses of the debugging capability of the VBA system, when I activate the control it should start the VBA code at Private Sub cboSelectPersonnel_DblClick(Cancel As Integer).

    However it does not. I put the form frmPersonnel in Form view and I select from the combo box a name (see the attached pdf for picture) and then it does not stop on the

    Private Sub cboSelectPersonnel_DblClick(Cancel As Integer).

    I have been debugging VBA code in MS Access for several months now and I believe that it should stop on the breakpoint that I created when I chose the combo box and chose a name. (See attached pdf file for picture of breakpoint).

    However, it does not and that is my question.

    Any help appreciated. Thanks in advance.

    Respectfully,

    Lou Reed
    Attached Files Attached Files

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    it works for me - perhaps you are not doubleclicking quick enough?

    Click image for larger version. 

Name:	Capture.JPG 
Views:	52 
Size:	45.5 KB 
ID:	29869

  3. #3
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    Why would you expect a combo box double click event to run when what you've done is select a name? The event that is likely needed after a combo selection is AfterUpdate, not DoubleClick.
    Am I interpreting this incorrectly?
    I select from the combo box a name (see the attached pdf for picture) and then it does not stop on the
    Private Sub cboSelectPersonnel_DblClick(Cancel As Integer).
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  4. #4
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    It's a guess - but are you trying to figure out why the SearchForRecord isn't working?
    The syntax was wrong - there were too many quotes, and since [PersonnelID] is numeric, it cannot be in quotes.

    I tried it like this:

    DoCmd.SearchForRecord , "", acFirst, "[PersonnelID] = " & [Screen].[ActiveControl]

    and it worked fine.

  5. #5
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    Okay, thank you very much. I will try it. Again this was translated from MS Access 2010 macros to VBA.

    Respectfully,

    Lou Reed

  6. #6
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    I have not made the change suggested, but I do note one thing and maybe it is relevant. When I select someone from the dropdown list say Boris Karloff, the confirmation message that pops up always asks if I am sure that I want to remove "Peter Cushing" from the list. if I had actually selected Peter Cushing that would be fine; but I selected Boris Karloff. Thus I am confused as to why it only selects Peter Cushing, never anyone else.

    Could this be because of the syntax error pointed out in Post #4.

    I do not know whether the go ahead and make that modification or to find out the cause of this error.

    It seems to be related. So maybe the syntax error pointed out in Post #4 is actually causing this.

    The zipped file with this error is in Post #1.

    Any help appreciated. Thanks in advance.

    Respectfully,

    Lou Reed

  7. #7
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    When I select someone from the dropdown list say Boris Karloff, the confirmation message that pops up always asks if I am sure that I want to remove "Peter Cushing" from the list.
    That is not possible. Just selecting from the dropdown does nothing - there is no code. Double-click on the dropdown does the record search, but there is no code to produce the message you are referring to.

    The message you see is coming from the ON_Click of the "Remove" button, and the code in there does not refer to the dropdown at all. Please clarify.

  8. #8
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    The attached screenshot should show the point I am trying to make. The selection here is for Lon Chaney(at the top); and the selection of employee to delete is for Peter Cushing. The name Peter Cushing is selected from the combo box below the next and previous keys. Then it asks me if I want to delete Lon Chaney!

    I do not. I want to delete Peter Cushing.

    I believe the names should be the same in all cases, between the name I selected and the warning message asking if I am sure that I want to delete that name. They are currently different and that is why I am posting this message. The name at the very top is not relevant (in this case Lon Chaney). I selected someone to delete and it just asks for a confirmation. Those two names should match.

    What am I doing wrong.

    Any help appreciated. Thanks in advance.

    Respectfully,

    Lou Reed
    Attached Files Attached Files

  9. #9
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    I believe the names should be the same in all cases, between the name I selected and the warning message asking if I am sure that I want to delete that name.
    That make sense, but your code is not doing that. The code behind the "Remove" button is referencing the record (name) that is on the form, not the one you selected in the combo box. What you should do is what was suggested by Micron in post #3, which is to search for and display the record matching the name selected in the combo box as soon as you select it, i.e. in the after update event of the combo, not the Double-click.

    You could modify the "Remove" code to reference the combo box instead of the form control, but I would not recommend that because you would not necessarily have the record to be removed displayed in the form.

  10. #10
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    Since I can never open LR's databases, I can only wonder about things. Like
    - why is an empty string being passed as the searchforrecord object name?
    - is [PersonnelID] a number yet the combo contains a name?
    - is the message box referring to a control I can't see ([FullName]) yet the active control that apparently holds the desired value is a combo box (the control related to the event code)?
    - do any of these factors result in a Where criteria that is not met, thus the focus stays on the current record??? That is the behaviour of this method.

  11. #11
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    Okay, I am just trying to understand how to get into the double-click Sub on the VBA code associated with frmPersonnel.

    I set a code stop in cboSelectPersonnel_DblClick. Then when walking through the VBA code it should stop at that point : if I can get into the sub routine!

    I opened the combo box on frmPersonnel to select, and selected say Boris Karloff.

    I then double-clicked on the name and nothing happened. It did not stop in the VBA source code where I wanted it to. I am not sure what or where I double click.

    I will change it to after_update once I am able to get into that Sub.

    Right now I cannot do that. Please help.

    A zipped db and screenshot (of where I want to go) are attached to this post. Just how do I get there?

    Any help appreciated. Thanks in advance.


    Respectfully,

    Lou Reed
    .
    Attached Thumbnails Attached Thumbnails Capture3.GIF  
    Attached Files Attached Files

  12. #12
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    Micron:

    Where is the PersonnelID a name and not a number I need to change that immediately.

    Thanks of r your help.

    Lou Reed

  13. #13
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    Okay, I selected Dwight Frye from the combo box. The name showed in the combo box window. I double clicked the name and got this error message that you see in the attached pdf. I thought that this was the correct way to get into the pdf. If it is then somethings is wrong, I should not get an error.

    The db and pdf are attached.

    Please help.

    Respectfully,

    Lou Reed
    Attached Thumbnails Attached Thumbnails Capture4.GIF  
    Attached Files Attached Files

  14. #14
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    First - change the DoCmd in your DoubleClick sub to what I showed you in post #4:


    DoCmd.SearchForRecord , "", acFirst, "[PersonnelID] = " & [Screen].[ActiveControl]

    It works - the way you have it now doesn't. You should fix the errors as soon as they are pointed out to you, because some of the following problems and errors are due to the first one.

    The error message you show above is coming from the sub UpdateButtons. The syntax in this statement is incorrect:

    If DCount("*", "tblPropertyPass", "[PersonnelID] = " & [Forms]![frmPersonnel].[PersonnelID] & " [isActive] = true") = 0 Then

    It should be:

    If DCount("*", "tblPropertyPass", "[PersonnelID] = " & [Forms]![frmPersonnel].[PersonnelID] & " AND [isActive] = true") = 0 Then

    Keep in mind that this statement does not reference the combo box, either. It is referencing the control called [PersonnelID].
    Last edited by John_G; 08-10-2017 at 01:21 PM. Reason: Add a comment

  15. #15
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    I appreciate the answers. First let me say that I do make the changes when they are posted here.

    This correction was done when you first posted it:

    DoCmd.SearchForRecord , "", acFirst, "[PersonnelID] = " & [Screen].[ActiveControl]

    If it got back in then wrong that it was my fault, I was moving db's around old and new. Somewhere the wrong one got in, That is clearly my fault. I take the blame.

    However, if I made a mistake it was bad organization.

    I do have one question though and that is if the syntax i used was wrong (and it was) when I corrected it everything was fine. But if the syntax was wrong why didn't the compiler catch it?

    That is normally my first line of defense, when I check for incorrect syntax.

    Also, as for changing from dblclick to after_update, I was not getting into the Sub regardless of what it was called I was going to change from dblclick to after_update when I finally got in the sub - one way or another.

    Also, I thought calling a function with no arguments in VBA was simply the name of the function with no arguments. Something like

    Do.Cmd.RunMacro "
    FormHeading"


    is now

    FormHeading


    However, when the expression is like this:

    DoCmd.RunMacro "Formheading", , ""

    it must be written like this:

    Formheading ", , "

    We now have arguments and they are :
    ", , ".

    This

    DoCmd.RunMacro "FormHeading", , ""

    cannot be the same as this:

    DoCmd.RunMacro "FormHeading"

    when it come to calling FormHeading in VBA. without or with arguments, respecttively. They just cannot be. They are different. That was the question that I asked several weeks ago.


    I will also change the IF DCount line to what you said.

    I never wrote that Sub. I understand the IF-THEN execution, but the criteria at the top:

    Code:
    Public Sub updateButtons()
        If DCount("*", "tblPropertyPass", "[PersonnelID] = " & [Forms]![frmPersonnel].[PersonnelID] & " [isActive] = true") = 0 Then
            Me.btnClose.Enabled = False
            Me.btnEditProperty.Enabled = False
            Me.btnNew.Enabled = True
        Else
            Me.btnClose.Enabled = True
            Me.btnEditProperty.Enabled = True
            Me.btnNew.Enabled = False
        End If
    The IF DCount... part was throwing me, I simply did not understand that executable line.

    It appears that I must replace & with AND.

    That is quite easy.

    Please understand that posting a nd waiting for replies can be awkward. I can get disorganized. In no way does that diminish my appreciation for your help.

    Respectfully,

    Lou Reed

Page 1 of 3 123 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Setting a breakpoint in code
    By Lou_Reed in forum Access
    Replies: 9
    Last Post: 08-04-2017, 12:03 PM
  2. Replies: 3
    Last Post: 05-28-2016, 07:35 AM
  3. Disabled Breakpoint continues to stop code
    By Glenn_Suggs in forum Access
    Replies: 3
    Last Post: 08-15-2014, 04:32 PM
  4. Phantom Breakpoint
    By Paul H in forum Programming
    Replies: 1
    Last Post: 10-03-2012, 01:30 PM
  5. Replies: 2
    Last Post: 11-29-2009, 12:00 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