3

While running my Access application, I receive a Error 53 File Not Found error.

enter image description here

The file in the error message refers to a referenced library for the application.

enter image description here

I refer to the library in my code like so...

Private Declare PtrSafe Sub ControlUnlockT Lib "Accusoft.TwainPro9.ActiveX.dll" Alias "PS_Unlock" _
(ByVal pw1 As LongPtr, ByVal pw2 As LongPtr, ByVal pw3 As LongPtr, ByVal pw4 As LongPtr)

And use the declared subroutine in the following function:

Public Function StartupSettings()

On Error GoTo Error_StartupSettings


'Hide menubars
'When used with the Application object,
'the MenuBar property enables you to display a custom menu bar
'throughout the database. However, if you've set the MenuBar
'property for a form or report in the database, the custom menu
'bar of the form or report will be displayed in place of the database's
'custom menu bar whenever the form or report has the focus.
'When the form or report loses the focus, the custom menu bar for the
'database is displayed.
'Application.MenuBar = "mcrBlankMenuBar"

ControlUnlockT DLookup("Code", "tblSecurity", "Section=1"), DLookup("Code", "tblSecurity", "Section=2"), _
        DLookup("Code", "tblSecurity", "Section=3"), DLookup("Code", "tblSecurity", "Section=4")
ControlUnlock DLookup("Code", "tblSecurity", "Section=1"), DLookup("Code", "tblSecurity", "Section=2"), _
        DLookup("Code", "tblSecurity", "Section=3"), DLookup("Code", "tblSecurity", "Section=4")

'Change the keyboard Move After Enter behavior to Next Field rather
'then next record or dont move
Application.SetOption "Move After Enter", 1

'Hide database window
DoCmd.Echo False
'DoCmd.SelectObject A_MACRO, "mcrOpenMDB2", True
'DoCmd.DoMenuItem 1, 4, 3, , A_MENU_VER20
DoCmd.Echo True



Exit_StartupSettings:
    Exit Function


Error_StartupSettings:
    MsgBox Err.Description, 16, "Error " & Err & " - StartupSettings"
    Resume Exit_StartupSettings


End Function

The file exists in the path, so what am I missing here?

enter image description here

Andre
  • 26,751
  • 7
  • 36
  • 80
Jade Cowan
  • 2,543
  • 1
  • 18
  • 32
  • Unless I'm very wrong, this is not an error message from Access, but one created by your code. Check the `StartupSettings` procedure (I assume). – Andre Mar 13 '18 at 21:47
  • @Andre, I'm only catching and displaying what function the error message is occuring in. The error 53 is coming from [VBA](https://msdn.microsoft.com/en-us/vba/language-reference-vba/articles/file-not-found-error-53). The ```StartupSettings``` contains the declared subroutine. – Jade Cowan Mar 13 '18 at 21:52
  • Thanks for the edit - so it's an error handler message. If you remove the error handler, does Access show a more informative error message? – Andre Mar 13 '18 at 21:59
  • 2
    Seems like you are trying to use a x86 dll (SysWow64) in x64 Excel (Declare PtrSafe). – ComputerVersteher Mar 13 '18 at 22:00
  • @Andre, without error handling the message is still the same. – Jade Cowan Mar 13 '18 at 22:05
  • @ComputerVersteher, a compiler error is thrown if PtrSafe attribute isn't added to Declare statements on a 64-bit system. Unless I'm misunderstanding the purpose of the attribute, it just means that the statement is safe to run on a 64-bit system. – Jade Cowan Mar 13 '18 at 22:10
  • 1
    As @ComputerVersteher wrote. If you are locked in with 64bit Access and the 32bit DLL, you have a problem. https://stackoverflow.com/questions/4219477/32-bit-dll-in-office-64-bit – Andre Mar 13 '18 at 22:10
  • Thank you for the insight. I'll look more into the link you sent, @Andre. – Jade Cowan Mar 13 '18 at 22:14
  • 2
    BTW, if you use functions declarations, you don't need library references. – Sergey S. Mar 14 '18 at 09:35

0 Answers0