capturing the computer id in a access querry

M

MGFoster

JoeJohnson said:
I want to capture the computer's id (or users id) in an access querry.

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

You'll have to call a user-defined function in the query. E.g.:

SELECT colA, colB, GetComputer() As ComputerName
FROM table_name

Here's the necessary functions:

' In the declaration section of a module
Public Declare Function GetComputerName Lib "Kernel32" Alias _
"GetComputerNameA" (ByVal strBuffer As String, lngBufferSize As
Long) _
As Long

Public Function GetComputer() As String
' From Access-VB-SQL Advisor, Vol 8. No 2., p. 17.
Dim strComputerName As String
Dim lngSize As Long
Dim lngLength As Long
strComputerName = String(16, " ")
lngSize = Len(strComputerName)
lngLength = GetComputerName(strComputerName, lngSize)
GetComputer = Left(strComputerName, lngSize)
End Function

Here's the user name functions:

' Declaration section...
Public Declare Function GetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal strBuffer As String, lngSize As Long) As Long

Public Function GetUser() As String
' One way:
' Will only work if the environment variable is set
' GetUser = Environ$("UserName")

' Another way:
' From Access-VB-SQL Advisor, Vol 8. No 2., p. 17.
Dim strUserName As String
Dim lngSize As Long
Dim lngLength As Long
strUserName = String(15, " ")
lngSize = Len(strUserName)
lngLength = GetUserName(strUserName, lngSize)
GetUser = Left(strUserName, lngSize - 1)
End Function

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBRKLpToechKqOuFEgEQJaQgCcDcu+wzIVNx6xSNZnnCit7hjfAZYAnR2X
Z/GrJV3EWFVuqRWCJnWaOcdc
=ewE2
-----END PGP SIGNATURE-----
 
J

JoeJohnson

Thanks MGFoster it worked!!!
--
Thanks Joe


MGFoster said:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

You'll have to call a user-defined function in the query. E.g.:

SELECT colA, colB, GetComputer() As ComputerName
FROM table_name

Here's the necessary functions:

' In the declaration section of a module
Public Declare Function GetComputerName Lib "Kernel32" Alias _
"GetComputerNameA" (ByVal strBuffer As String, lngBufferSize As
Long) _
As Long

Public Function GetComputer() As String
' From Access-VB-SQL Advisor, Vol 8. No 2., p. 17.
Dim strComputerName As String
Dim lngSize As Long
Dim lngLength As Long
strComputerName = String(16, " ")
lngSize = Len(strComputerName)
lngLength = GetComputerName(strComputerName, lngSize)
GetComputer = Left(strComputerName, lngSize)
End Function

Here's the user name functions:

' Declaration section...
Public Declare Function GetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal strBuffer As String, lngSize As Long) As Long

Public Function GetUser() As String
' One way:
' Will only work if the environment variable is set
' GetUser = Environ$("UserName")

' Another way:
' From Access-VB-SQL Advisor, Vol 8. No 2., p. 17.
Dim strUserName As String
Dim lngSize As Long
Dim lngLength As Long
strUserName = String(15, " ")
lngSize = Len(strUserName)
lngLength = GetUserName(strUserName, lngSize)
GetUser = Left(strUserName, lngSize - 1)
End Function

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBRKLpToechKqOuFEgEQJaQgCcDcu+wzIVNx6xSNZnnCit7hjfAZYAnR2X
Z/GrJV3EWFVuqRWCJnWaOcdc
=ewE2
-----END PGP SIGNATURE-----
 
Top