I have a form for inputting notes which has a submit button. When the button is clicked I need a copy of what was typed appended to the top of a log. All works fine there. However to increase tracability i also want to append the username and date/time the note was created. The date is easy but how do I retrieve the windows username ?? I'm using office 2003
Thanks in advance
9 1289
I have a form for inputting notes which has a submit button. When the button is clicked I need a copy of what was typed appended to the top of a log. All works fine there. However to increase tracability i also want to append the username and date/time the note was created. The date is easy but how do I retrieve the windows username ?? I'm using office 2003
Thanks in advance
A simple API Call will enable you to retrieve the Window's User Name as in:- Declare this Function Publically in a Standard Code Module.
- Public Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
- Retrieve the value via the illustrated code below.
- Dim lngLength As Long, strUserName As String, lngRetVal As Long
-
-
strUserName = String$(254, 0)
-
lngLength = 255
-
-
lngRetVal = GetUserName(strUserName, lngLength)
-
-
strUserName = Left$(strUserName, lngLength - 1)
-
-
'value now contained in strUserName
-
Debug.Print "The Current Windows User is " & strUserName
OUTPUT: - The Current Windows User is Armund P
I've used this before: - CurrentUser() & " @ " & Now()
which yields
Linq @ 7/19/07 9:53:24 PM
Good Luck!
Linq ;0)>
Cheers mate, it worked a treat!
I've used this before: - CurrentUser() & " @ " & Now()
which yields
Linq @ 7/19/07 9:53:24 PM
Good Luck!
Linq ;0)>
I have a form for inputting notes which has a submit button. When the button is clicked I need a copy of what was typed appended to the top of a log. All works fine there. However to increase tracability i also want to append the username and date/time the note was created. The date is easy but how do I retrieve the windows username ?? I'm using office 2003
Thanks in advance
The date is easy but how do I retrieve the windows username ??
Be advised that CurrentUser() will not retrieve the User's Name who is logged on to Windows but will return the Current User of the Database.
If you want to know the person who just made an entry in the database, wouldn't that be the Current User of the Database as opposed to the person who booted up Windows?
Actually, its always returns 'Admin' on every workstation it is run on!
OK, so it looks like I have to use this bit of code but can't find when to put the declaration statement. A simple API Call will enable you to retrieve the Window's User Name as in:- Declare this Function Publically in a Standard Code Module.
- Public Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
- Retrieve the value via the illustrated code below.
- Dim lngLength As Long, strUserName As String, lngRetVal As Long
-
-
strUserName = String$(254, 0)
-
lngLength = 255
-
-
lngRetVal = GetUserName(strUserName, lngLength)
-
-
strUserName = Left$(strUserName, lngLength - 1)
-
-
'value now contained in strUserName
-
Debug.Print "The Current Windows User is " & strUserName
OUTPUT: - The Current Windows User is Armund P
OK, so it looks like I have to use this bit of code but can't find when to put the declaration statement.
OK, so it looks like I have to use this bit of code but can't find when to put the declaration statement.
As indicated in Item #1 from the Response, in a Standard Code Module.- Select the Modules Tab in the Database Window.
- New.
- With (General) visible in the left drop down, and (Declarations) visible in the right drop down, paste the Function Declaration.
If you want to know the person who just made an entry in the database, wouldn't that be the Current User of the Database as opposed to the person who booted up Windows?
Your logic is sound, ling but I was simply responding to the OP's request.
The date is easy but how do I retrieve the windows username ??
Sign in to post your reply or Sign up for a free account.
Similar topics
by: dmiller23462 |
last post by:
Hey guys....
I put an error-handling in my page and have it posted at the complete
end of the code, see below(when people were putting in 's I was
getting the delimiter errors). Great, I...
|
by: Michael |
last post by:
I have a data application in a2k that I need to create two fixed width
text files and then combine them to a single file The first file is
header information and the second is transaction data. ...
|
by: MLH |
last post by:
I have a query, qryAppend30DayOld260ies that attempts to append
records to tblCorrespondence. When run, it can result in any of the
following: appending no records, appending 1 record or appending...
|
by: Rein Petersen |
last post by:
Hi All,
I'm having a heckuva time trying to append lines into my multiline readonly
System.Windows.Forms.TextBox
I was expecting to simply do this:
myTextBox.Text += "appending this line...
|
by: Mike P |
last post by:
Does anybody have a simple example of appending text to a text file?
Cheers,
Mike
*** Sent via Developersdex http://www.developersdex.com ***
|
by: mikemac76 |
last post by:
I am trying to build a test harness to practice appending strings to an rtf
string. I am doing this to simulate the string I'll be sending over the wire
and receiving on the other end of an IM...
|
by: Jared |
last post by:
Hello all,
I'm looking for the best way to wrap my cell contents in a html label
tag. The results I'm looking for will allow the user to select the checkbox
when any cell in the tablerow is...
|
by: John A Grandy |
last post by:
could someone explain the following to me :
Appending the literal type character I to a literal forces it to the Integer
data type. Appending the identifier type character % to any identifier...
|
by: Donald Grove |
last post by:
Is it possible to append records to a space delimited text file, using
Access 2000?
|
by: Jim |
last post by:
Could anyone please point me towards some code that allows me to add to an
existing XML file using the output of an HTML form.
I want to add a form on my website so users can input their email...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |