Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 14th, 2004, 11:02 AM
Registered User
 
Join Date: Sep 2004
Location: , , .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default Global Varibles?

Ok what I believe I am asking for is a Global variable? Well it sounds good any way what I am trying to achieve is the tracking of a user login in to the database. I have a form which allows the user to login which I wish to be able to draw on this at many occasions.

Am I able to do this?
Or am I barking up the wrong tree completely?

Simon


Reply With Quote
  #2 (permalink)  
Old December 14th, 2004, 05:08 PM
Authorized User
 
Join Date: Jul 2004
Location: clapton-in-gordano, n.somerset, United Kingdom.
Posts: 46
Thanks: 0
Thanked 1 Time in 1 Post
Default

Sort of the wrong tree.

By using Application.Currentuser you can get the login name at the computer, but by using an API call you can get the network login name. In both instances record the name in a text box on the login form (hidden if necessary) and simply refer to this textbox when you need the information.

Somewhere in my code I have the API call, if you want it I can find it

Cheers

Alan Thomas

Reply With Quote
  #3 (permalink)  
Old December 15th, 2004, 08:56 AM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Hi,

   Sorry to butt in, but I would like to see that API call to get the network ID. I have similar issues but have given up until we move from (gulp) NetWare (which totally prevents the use of Access security) to Microsoft.

   Hey, why do you think my username is in 8.3 format? DOS lives, somewhere... apparently at my job site.

Thanks,


mmcdonal
Reply With Quote
  #4 (permalink)  
Old December 18th, 2004, 11:31 AM
Authorized User
 
Join Date: Jul 2004
Location: clapton-in-gordano, n.somerset, United Kingdom.
Posts: 46
Thanks: 0
Thanked 1 Time in 1 Post
Default

API call as follows

'---------------------------------------------------------------
Declare Function wu_GetUserName Lib "advapi32.dll" Alias _
   "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) _
   As Long
'---------------------------------------------------------------
Function ap_GetUserName() As Variant

   Dim strUserName As String
   Dim lngLength As Long
   Dim lngResult As Long

   strUserName = String$(255, 0)
   lngLength = 255

   lngResult = wu_GetUserName(strUserName, lngLength)

   ap_GetUserName = Left(strUserName, InStr(1, strUserName, Chr(0)) - 1)

End Function
'-----------------------------------------------------------

This works in MOST OS/Network combinations, but it does sometimes have problems with NT4. Good Luck



Reply With Quote
  #5 (permalink)  
Old December 18th, 2004, 11:36 AM
Authorized User
 
Join Date: Jul 2004
Location: clapton-in-gordano, n.somerset, United Kingdom.
Posts: 46
Thanks: 0
Thanked 1 Time in 1 Post
Default

Whilst i'm at it, here is the code to get the computer name of the current user

Declare Function wu_GetComputerName Lib "kernel32" Alias _
   "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) _
   As Long
‘=============================================== ==========

Function ap_GetComputerName() As Variant

   Dim strComputerName As String
   Dim lngLength As Long
   Dim lngResult As Long

   strComputerName = String$(255, 0)
   lngLength = 255

   lngResult = wu_GetComputerName(strComputerName, lngLength)

   ap_GetComputerName = Left(strComputerName, InStr(1, strComputerName, Chr(0)) - 1)

End Function

Alan Thomas

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to declare the global variable in global.asax? calyn_gately ASP.NET 3.5 Basics 0 August 6th, 2008 08:06 PM
PHP varibles in FLASH Ashleek007 Beginning PHP 1 November 30th, 2004 12:44 PM
How to do a mysql update using varibles in a query Alex_forever MySQL 5 April 28th, 2004 09:34 PM
Varibles between asp.net and Asp Pages koneruvijay VS.NET 2002/2003 1 February 23rd, 2004 04:32 AM
Global On? anim BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 1 October 10th, 2003 11:58 AM



All times are GMT -4. The time now is 09:20 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.