Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

refrencing a custom dll fails 2

Status
Not open for further replies.

jordanking

Programmer
Sep 8, 2005
351
Hello,

I cannot refrence a custom dll given to me by simply accounting. So i do not know what program created it or if that even matters. I can refrence other dll and have tried both browsing to the file under the tools menu and coding the function directly into VBA:

Application.VBE.ActiveVBProject.References.AddFrom File "C:\Program Files\Simply Accounting SDK\SDK\sa_dblyr.dll"

I really have no idea why I cannot refrence it. I could attach the dll for anyone but do not know how.
 
You don't say what occurs when you try to reference the dll. Error message?


Regards,
Mike
 
Sorry,

An error message appears that says
"Can't add a reference to the specified file"

 
From what I have been able to find, that error message appears when trying to create a reference to a dll that does not contain a type library. You mentioned the file was given to you by Simply Accounting. For what purpose? Any documentation provided?

Regards,
Mike
 
Thank you for the reply

The dll that I was given was a part of a SDK. It is supposed to contain the full library of functions for accessing and manipulating the simple accounting database. They have inclued an example of VB code that works with the dll. But for some reason VBA cannot refrence it.

The simply documentation says that simply uses an ADO to access the database.

The following is what they included about the dll library and the runtime environment:

The Simply Accounting database routines requires Jet 4.0, MDAC2.6 and MFC 6.0 installed in your
system. If you have previously installed Simply Accounting, all the required files should already be
present. If the target machine does not have Simply Accounting installed, refer to the following
Microsoft Knowledge Base articles for more information:
Microsoft Data Access Components (MDAC) 2.60.6526.3
82ad1d514737&DisplayLang=en
Redistributing Microsoft Visual C++ 6.0 Applications
Since the DLLs are 32-bit, the SDK will only work with 32-bit compilers running on Windows
98SE/NT/2000. In addition, the same limitation applies to any application that utilizes the
included DLLs. In order for applications to execute properly, the following files must be distributed
with the application: sa_dbdrv.dll, sa_dblyr.dl, sa_tlsmgr.dll and sa_utils.dll.
For Microsoft Visual C++ users: The included library file(sa_dblyr.lib) will only work with Microsoft
Visual C++ 6.0. If your development compiler does not meet this requirement, you could still use
the provided DLL if explicit linking to the DLL is done. Call the LoadLibrary function to link to the
DLL explicitly and then call GetProcAddress to obtain the address of the exported function in the
DLL. For more information on LoadLibrary and GetProcAddress, refer to the Visual C++
Documentation.


Does this mean that only C++ can refrence this library? I don't know anyhting about dll and refrencing so I might be missing something obvious.

Thank you for the time

Jordan King
 
Maybe you have to register (regsvr32) the DLL ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
PHV,

That's what I initially thought, but was able to set a reference to a library (dll) that I un-registered (which isn't to say that I would actually be able to use it).

Jordan,

It is not clear whether VBA will work with this or not, although the fact that Simply Accounting has supplied a VB example would indicate yes (there are more similarities than differences between VBA & VB). If there are specific instructions for use with VB that might help. Otherwise, I would contact technical support and ask the question directly (regarding use with Office/VBA). I'm a little out of my depth here... perhaps someone else has other ideas.

Regards,
Mike
 
Perhaps a Declare instruction instead of a reference ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
PHV

sorry, I don't know what you mean by registering a dll. Also, I don't know what you mean by a declare statment. This is the first time i have worked with dlls.

rmikesmith and phv
thanks for your time.

Jordan
 
I googled how to register and I tried to register the DLL but this error came up:

"sa_dblyr.dd was loaded, but the dllRegisterServer entry point was not found"

Jordan

 
Can VBA refrence a API library. How? Is that the delcare statement. Or am I out of luck?

Thanks Jordan
 
When in the debug window (Ctrl+G) type declare and press the F1 key.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
PH

This is the declare statement that I used:

Private Declare Function wSDBOpenDatabase Lib "C:\Program Files\Simply Accounting SDK\SDK\sa_dblry.dll" () As Long

It did not work. The file path is correct but Simply accounting (company who provided me with the dlls) included two files; sa_dblyr.dll and sa_dblyr.lib, and some support dlls to the main library. I tried both files and they did not work. The function "wSDBOpendatabase" is in the library for sure. Are there arguments in the declare statement that I am missing that might be the cause? I read the documentation on the optional arguments at the end on the declare statement and did not understand completley.
 
And no documentation from Simply accounting ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
I found the declare statement in the VB example that Simply accounting sent me. It was in a seperate "Module1.bas" file:

Public Declare Function wSDBOpenDatabase Lib "sa_dblyr.dll" (ByVal pszFileName As String, ByRef pDBLinkNo As Integer, ByVal wFlags As Integer, ByVal pszAppID As String, ByVal pszUserID As String, ByVal pSZPWD As String, ByVal pszRsrvd1 As String, ByVal pszRsrvd1 As String) As Integer

I tired to cut and past this into my code for a "Private Sub cmdOK_Click()" event.

But i get a unique error event from access when i click the button. It does not even attempt to open the debugger. It just opens a warning window saying that "Only comments may appear after End Sub, End FUnction, or End Property." and attaches the following help text:

Visual Basic for Applications (VBA) encountered a problem while attempting to access a property or method. The problem may be one of the following:

A reference is missing.
For help restoring missing references, see the Microsoft Knowledge Base article 283806.

An Expression is misspelled.
Check all expressions used in event properties for correct spelling.

A user-defined function is declared as a sub or as a private function in a module.
Expressions can resolve a user-defined function only if the function is declared as one of the following:
A public function in a module
A public or private function in a code module of the current form or report
Security in Access is set to Medium or High and the Microsoft Jet 4.0 SP8 update is not installed.
A more recent verion of Jet 4.0 must be installed for Access to function properly when security is set to Medium or High. To obtain the latest version of Microsoft Jet, go to Windows Update.
 
I strongly recommend NOT to play with API calls if you don't have a mininum VBA knowledge.
 
I am setting up a link between a new databse in access and a new empty simply accounting program. So even if I delete all data or something similar there is no problem. Is there something else more fatal i could do. I only need to pass some elements of a query into a one or two tables in the simply accounting database. The sdk shows full working example of this in VB, C++, and delphi. I am somewhat familiar with VBA so am attempting it from VBA. Simply has sent full documentaion of the functions and thier arguments. I just cannot refrence/declare them in VBA.

I really do appreciate all the time you are puttin into this PHV.

Jordan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top