Consulting

Results 1 to 2 of 2

Thread: Freezes After Launching Access.Application function

  1. #1

    Freezes After Launching Access.Application function

    So I have a button in outlook that saves a email, then copies the file's name, and file path to an "Access" database. It does complete the function, but what ends up happening is after the button is clicked, Outlook freezes up(including vba editor). About 30 seconds later, a windows msg box says "Microsoft access has stopped working" then it says "Microsoft access is restarting" then it launches Access. I looked into the table and the record was added properly.

    I tried it while Access was opened and tried it with it closed, same resort. Whats weird is if you look at the code below, I added at the very end of the function, debug.print done, to say it finished. So after I press the button, in vba editor, it does print it out before outlook starts freezing. Any help would be appreciated

     'open up an access database and insert a new record, specifically the filename and path
      Set accessApp = New Access.Application
      strSQL = "INSERT INTO tbleFiles(FileName,FilePath,FileFormat,FileType_ID) VALUES ('" & sName & "','" & sPath & "','" & ext & "','" & 1 & "');"
      Call accessApp.OpenCurrentDatabase("C:\Users\Derek\Documents\SmallProjecttest.accdb")
      accessApp.Visible = False
      accessApp.CurrentProject.Connection.Execute (strSQL)
      accessApp.Quit
      Debug.Print "Done"

  2. #2
    So I found out the reason for why this was happening. I first tried AccessApp.quit acQuitSaveAll which made it faster, but instead of happening after 30 seconds, its within 2-5 seconds. So I created a pause function which will wait 5 seconds(this seemed to be the sweet spot) and now I don't have anymore problems. I noticed part of the problem is that it kept an instance up of the Access database and that was part of the issues. I assume it was going to fast to close the instance down?

Posting Permissions

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