Results 1 to 3 of 3
  1. #1
    allan is offline Novice
    Windows 11 Access 2016
    Join Date
    Oct 2024
    Posts
    1

    VBA editor hangs when adding a breakpoint even though function runs without break

    Hi everyone,
    I am seeing the oddest behavior in the VBA editor when I add a breakpoint in an access function I created. I've been working to simplify the issue down to try and get to root cause, unsuccessfully.

    The issue: When I add a breakpoint on a function in VBA, on a sub-query, and I pass any of my table parameters to the function, VBA hangs. It stops on the breakpoint and I can't step through. My table is trival - its a regular table, filled with dates, numbers, and string and has < 10K rows.

    That said, the function will allow met to step through at the breakpoint under any of these conditions:

    1. If I pass a fixed value (string, null, number, date) it doesn't hang! It works fine. I put the breakpoint and viola, I can step through.
    2. If I don't have a breakpoint in the function (just run query normal), even when I pass my parameter, IT WORKS fine. It just runs as expected.
    3. And If it's not a sub-query, it works fine;. I can step through the function. I need it to be a sub-query, though so I can select based on a weekending date.

    It's only when it's a sub-query, and I pass a field value to the function, it hangs at the breakpoint.

    I created the most simple query and function I could think of, and I can't figure out to save my neck. Here's my example:

    My function:

    public function doNothing(myField)
    doNothing = 1
    end function

    =================================

    My query:

    SELECT
    weekending,
    count(*),

    (SELECT
    avg(doNothing(field1))
    FROM myTable as T2
    WHERE
    T1.weekending = T2.weekending) as testThis

    FROM
    myTable as T1

    GROUP BY
    weekEnding;

    ==================



    Again, the VBA editor hangs on the breakpoint only if it is passed the parameter, not a fixed value. And if I have no breakpoint, i get the results back as expected. I've been a programmer forever, and never have seen this.

    Anyone ever see it?
    Last edited by allan; 10-08-2024 at 02:20 PM. Reason: typo

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,574
    Nope.
    Upload a sample db with instruction on how to recreate.
    You could try a repair of office, or use another computer. That was my reason for asking for the dB, to test on another computer.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,425
    Never tried that. As I see it, your query build is in one procedure and you're expecting it to branch to another procedure, process what was passed, then come back exactly where it was in the middle of building that sql and carry on. It wouldn't occur to me to try that and maybe it should work but I suspect you're creating a circular reference sort of loop. Maybe you could fix it with Do Events, but my approach would be to assign the returned value of a function call to a variable in the second procedure and use that in the sql.
    Last edited by Micron; 10-08-2024 at 03:22 PM. Reason: clarification
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. Query Editor, Form Explorer, Rowsource editor
    By davegri in forum Sample Databases
    Replies: 24
    Last Post: 04-25-2023, 08:09 AM
  2. Replies: 2
    Last Post: 12-07-2020, 08:52 AM
  3. Replies: 2
    Last Post: 01-23-2015, 12:14 PM
  4. Replies: 9
    Last Post: 10-17-2012, 11:37 AM
  5. Replies: 0
    Last Post: 01-20-2012, 03:41 PM

Tags for this Thread

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