By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,379 Members | 3,035 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,379 IT Pros & Developers. It's quick & easy.

MS Access VBA, all my Api calls return EMPTY

P: 5
I am using Access 2003 and no single Api call will work??
All my Api calls return EMPTY .

Some examples I tried:
Expand|Select|Wrap|Line Numbers
  1. Declare Function apiGetVersion Lib "kernel32" Alias "GetVersion" () As Long
  2.  
  3. Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
  4.  
  5. Declare Function api_GetUserName Lib "c:\windows\system32\advapi32.dll" Alias _
  6. "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
  7.  
  8. Private Declare Function gethostbyname Lib "WSOCK32.DLL" (ByVal hostname As String) As Long
  9.  
  10. Private Declare Function inet_addr Lib "WSOCK32.DLL" (ByVal s As String) As Long
  11.  
When calling no errors occur but the return value is always zero.
I use MS Access 2003 and my computer(s) run Windows XP Pro (SP2).

The last time I needed to use Api calls was with Access 8 and Windows 95, canít remember that is was such a struggle.

I really hope someone can help me with this.

Thanks,
Raymond
Apr 9 '08 #1
Share this Question
Share on Google+
8 Replies


FishVal
Expert 2.5K+
P: 2,653
Hi, Raymond.

Did you check error code?
If not, then get it with Err.LastDllError property and refer to System Error Codes.

Regards,
Fish
Apr 9 '08 #2

P: 5
Hi Fish,

Thank you for your fast reply.
The strange thing is that I don't get any error.
For example if I use this code:
Expand|Select|Wrap|Line Numbers
  1. Private Declare Function GetComputerName Lib "Kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
  2.  
  3. Public Function GetPcName() As String
  4.     Dim strBuf As String * 16, strPcName As String, lngPc As Long
  5.     lngPc = GetComputerName(strBuf, Len(strBuf))
  6.     If lngPc <> 0 Then
  7.         strPcName = Left(strBuf, InStr(strBuf, vbNullChar) - 1)
  8.         GetPcName = strPcName
  9.     Else
  10.         GetPcName = vbNullString
  11.     End If
  12. End Function
No errors occur and err.LastDllError=0 all the time.
lngPc will return 0 after calling GetComputerName.
This happens with all my Api calls, no errors but also nothing happens.

:( Raymond
Apr 9 '08 #3

FishVal
Expert 2.5K+
P: 2,653
Hi, Raymond.

The code runs fine. The only idea I have is that you may have missing references to external libraries. Have you checked this?
Apr 9 '08 #4

P: 5
Hi, Raymond.

The code runs fine. The only idea I have is that you may have missing references to external libraries. Have you checked this?
I use the following Libraries:
Visual Basic For Applications
Microsoft Access 11.0 Object Library
Microsoft DAO 3.6 Object Library
Microsoft ActiveX Data Objects 2.5 Library
Microsoft Visual Basic for Application Extensibility 5.3
Microsoft Windows Common Controls 6.0
Microsoft Forms 2.0 Object Library

Do I miss something or is this not what you mean?
Apr 10 '08 #5

P: 5
Hi Fish,

I re-installed Windows XP and MsAccess 2003 on new computer and now everything works fine.

Don't now what happened to my other systems.

Thanks for the time you spent helping me,
Raymond
Apr 10 '08 #6

FishVal
Expert 2.5K+
P: 2,653
You are welcome.
Good luck.
Apr 10 '08 #7

P: 5
Apparently the anti virus software from Kaspersky seems to be problem

Always the Russians! ;)

Raymond
Apr 10 '08 #8

FishVal
Expert 2.5K+
P: 2,653
They are everywhere. ;)
Apr 10 '08 #9

Post your reply

Sign in to post your reply or Sign up for a free account.