I have a dll, Prorfl.dll from HotelLock. I am integrating it into my Access VBA, but it is giving error nor result

133 Views Asked by At

The Prorfl.dll has been referenced as follows

Declare Function initializeUSB Lib "C:\Klax\WKNL\proRFL.dll" (ByVal fUSB As Byte) As Boolean

I get an error calling the function InitializedUSB(1):

file 'C:\Klax\WKNL\proRFL.dll' not found

I have tried to be sure of the path and confirmed severally. My ultimate aim is to be able to integrate this Dll into my Access software Via VBA

1

There are 1 best solutions below

6
Albert D. Kallal On BEST ANSWER

As noted, and suggested in the comments and discussion here, the only requirement to use x32 bit. dll’s is to ensure that you are running office/Access x32 bits.

From Access, (2010-2013), then go

File-Help, and you see this:

enter image description here

Note above - how we see x32 bits.

For 2016 (and later), then

File->Account

You see this:

enter image description here

You thus/then have to click on About Access, and you see this:

enter image description here

So, once again, I'm running x32 bit Access/office in above, and this is despite the windows OS being x64 bits. As noted, the windows OS for at least 10+ years has been defaulted to x64 bits, and your OS version will in near all cases these days be x64 bits, and that does not matter, nor effect the ability to install Access/Office x32 bits.

As I stated, this was a common setup, and still is. However, now by default, most installs of office are now defaulting x64 bits.

So, you can't mix and match x32 bit software with x64 bit software (and the reverse is also true).

Hence, your office/Access install has to match the bit size of that supplied .dll.

Edit: Follow up and solution

Ok, so the .dll code should work. The issue is that the current default path (folder) name needs to be set. In most cases, this is not required, but since additional .dlls depend on the referenced .dll, then you HAVE to change the current directory to the current folder where the addtional .dll's exist.

Interesting, but in Access 2016/2019, the posted code just works.

But, in Access 2010, the posted code DOES NOT work.

So, this issue has to do with having set the "default" folder for Access to use on startup.

Hence, before using any of the "declared" functions, simply execute a change folder in VBA.

Hence this code works:

Sub Test2()


   ChDir CurrentProject.Path
   
   Debug.Print initializeUSB(mP)
   
   
End Sub

So, Access does not seem able to pick up the .dll's unless you first execute a folder change, so Access can see/use/find the additional .dlls referenced.

You can also create a shortcut to the accdb, but to avoid this issue, simply execute a change folder to the current folder.