Hi, I want to now the name of the computer with my Access program. I found this code, but it doesn't work properly. Does anybody know how to use API's with VBA in Access.
I'll put the code:
IN THE MODULE:
Public Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, _
nSize As Long) As Long
Public Function Computer() As String
Dim Name As String * 255, Answer As Long, Length as Long, Res As Long
Name = ""
Length = Len(Name)
Res = GetComputerName(Name, Length)
If Res and Length > 0 Then
Computer = Left$(Name, Length)
Computer = "Doesn't found"
IN THE FORM:
Private Sub Form_Load()
Download for FREE the ADO/DAO Data Controls that makes life EASIER developing database applications in: VB, FoxPro, Access, VC++, .NET etc... Navigate, Add New, Delete, Update, Search, Undo and Save your changes. Supports Disconnected Recordsets and Transactions!
Or try our Ask An Expert service to answer any of your questions!