Consulting

Results 1 to 5 of 5

Thread: File not found during execution

  1. #1
    VBAX Contributor
    Joined
    Apr 2014
    Posts
    109
    Location

    File not found during execution

    This is a strange behaviour that sometimes resets when the whole computer is shut down and restarted - but sometimes not. It does not reset when the database is closed and restarted.

    I have a simple VBA code on a button, to open a simple form in which the user enters the date, and selects submit. The code works. Except when it does not.

    So my staff member clicked the button. Error warning pops up saying, File not found. When you try to close the button it warns that the debug process will also be closed. It didn't give the option of starting the debug process even though it does open the VBA code. If you try again, Access 2016 crashes. So start Access again, and try again. Same problem. Can repeat it many times.

    So instead, after opening the database program, I did a Ctrl-G to open the code. I went to the code for that button, and pressed the <F9> to do a step by step through the code so as to find where the problem is. But it did a step by step all the way through. I closed the code window and the form now opened, went back to the menu and clicked the button to run the code and now it works. This has happened more than once before.

    So 3 questions... though the last one matters most.
    1. What? Why does it work step by step when failing to work on execution?
    2. Why does the step by step somehow fix the problem?
    3. Is there a way for me to apply a fix at run time? I can code the OnError trigger to send the code to do something that in effect would do what the step by step is doing without having to stop and actually do so manually. But what would that code say or do?

    Sorry... am so confused.

    Gary

  2. #2
    VBAX Guru
    Joined
    Mar 2005
    Posts
    3,296
    Location
    I wonder if it could be a timing issue, the fact that you slow the code down by stepping through it.
    If you use a fixed date, ie no user input does it still crash?
    Do you currently use Error trapping?

  3. #3
    VBAX Contributor
    Joined
    Apr 2014
    Posts
    109
    Location
    Hmm, I don't know why the timing would be a problem.

    Here is a snippet of the code on that page. It sends to CmdPrintDpst_Click.

    Private Sub CmdPrintDpst_Click()
    SetVars
    DoCmd.OpenForm "GetDate", acNormal, , , , acDialog '<-------------This is where it errors.
    DoCmd.OpenReport "ItemizedTablesAsOne_DpstReport", acViewReport
    Report_ItemizedTablesAsOne_DpstReport.Requery
    End Sub


    Private Sub SetVars()
    MyYr = Year(Date)
    MyFYr = MyYr
    GetMyFYr 'this is a function that sets the fiscal year by checking the current month and applying an if statement
    End Sub


    It usually works. None of those seem to be timing issues. The error seems to suggest that the "GetDate" form doesn't exist. But the form can be opened manually. So the code must be changing the name of the file or something.
    As you can see, I didn't include error trapping in either of these codes.

    The last time it happened, I tried a different fix. I copy/cut the entire page of code under that form and paste it to Notebook. (one of my favorite applications as it doesn't see anything but text.). I then save the code as empty. Then I copy from Notebook and paste back to Access and Save. It worked.

    I believe what that does is remove some unseen corruption? I don't know, it has worked for me to fix other seeming corruptions.

    Gary

  4. #4
    • Check your javac path on Windows using Windows Explorer C:\Program Files\Java\jdk1. 7.0_02\bin and copy the address.
    • Go to Control Panel. Environment Variables and Insert the address at the beginning of var. ...
    • Close your command prompt and reopen it,and write the code for compile and execution.

  5. #5
    VBAX Contributor
    Joined
    Apr 2014
    Posts
    109
    Location
    Quote Originally Posted by mike smith View Post
    • Check your javac path on Windows using Windows Explorer C:\Program Files\Java\jdk1. 7.0_02\bin and copy the address.
    • Go to Control Panel. Environment Variables and Insert the address at the beginning of var. ...
    • Close your command prompt and reopen it,and write the code for compile and execution.

    Mike, can you please explain what this has to do with my problem? I am using VBA, not Java.

    Gary

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •