473,466 Members | 1,404 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

MS Access VBA, all my Api calls return EMPTY

5 New Member
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
8 2213
FishVal
2,653 Recognized Expert Specialist
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
rpie
5 New Member
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
2,653 Recognized Expert Specialist
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
rpie
5 New Member
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
rpie
5 New Member
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
2,653 Recognized Expert Specialist
You are welcome.
Good luck.
Apr 10 '08 #7
rpie
5 New Member
Apparently the anti virus software from Kaspersky seems to be problem

Always the Russians! ;)

Raymond
Apr 10 '08 #8
FishVal
2,653 Recognized Expert Specialist
They are everywhere. ;)
Apr 10 '08 #9

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

Similar topics

3
by: Mario | last post by:
Hello, I couldn't find a solution to the following problem (tried google and dejanews), maybe I'm using the wrong keywords? Is there a way to open a file (a linux fifo pipe actually) in...
6
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much...
4
by: hinrich | last post by:
Hello, I have a completely new system (windows xp prof.), office xp 2002 with sp 3. When I create a new and empty Accesss database, create an empty table and then create a new form using a...
7
by: dog | last post by:
I've seen plenty of articles on this topic but none of them have been able to solve my problem. I am working with an Access 97 database on an NT4.0 machine, which has many Access reports. I...
11
by: Grasshopper | last post by:
Hi, I am automating Access reports to PDF using PDF Writer 6.0. I've created a DTS package to run the reports and schedule a job to run this DTS package. If I PC Anywhere into the server on...
1
by: John | last post by:
Hi, Maybe someone can help me with the following: "The first task by any derived class constructor is to call it’s direct or indirect base class constructor implicitly or explicitly", reads the...
28
by: Gil | last post by:
can i have a client pc trigger access.exe to open on the server side pc? i want to have the server run special functions and return the output to the clients without having the clients run the...
21
by: lesperancer | last post by:
I've got an access97 reporting mdb that pulls data (77,000 rows) from a sql server table into a local table to run reports if the local table is part of the reporting MDB, the insert statement...
17
by: Arjen | last post by:
Hi, I want to reload 2 divs at one click. Ive tried: <a href = "javascript:void(0);"...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.