473,383 Members | 1,863 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Appending to text

jimleon
74
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
Jul 20 '07 #1
9 1289
ADezii
8,834 Expert 8TB
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:
  1. Declare this Function Publically in a Standard Code Module.
    Expand|Select|Wrap|Line Numbers
    1. Public Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
  2. Retrieve the value via the illustrated code below.
    Expand|Select|Wrap|Line Numbers
    1. Dim lngLength As Long, strUserName As String, lngRetVal As Long
    2.  
    3. strUserName = String$(254, 0)
    4. lngLength = 255
    5.  
    6. lngRetVal = GetUserName(strUserName, lngLength)
    7.  
    8. strUserName = Left$(strUserName, lngLength - 1)
    9.  
    10. 'value now contained in strUserName
    11. Debug.Print "The Current Windows User is " & strUserName
OUTPUT:
Expand|Select|Wrap|Line Numbers
  1. The Current Windows User is Armund P
Jul 20 '07 #2
missinglinq
3,532 Expert 2GB
I've used this before:

Expand|Select|Wrap|Line Numbers
  1. CurrentUser() & " @ " & Now()
which yields

Linq @ 7/19/07 9:53:24 PM

Good Luck!

Linq ;0)>
Jul 20 '07 #3
jimleon
74
Cheers mate, it worked a treat!

I've used this before:

Expand|Select|Wrap|Line Numbers
  1. CurrentUser() & " @ " & Now()
which yields

Linq @ 7/19/07 9:53:24 PM

Good Luck!

Linq ;0)>
Jul 20 '07 #4
ADezii
8,834 Expert 8TB
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.
Jul 20 '07 #5
missinglinq
3,532 Expert 2GB
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?
Jul 20 '07 #6
jimleon
74
Actually, its always returns 'Admin' on every workstation it is run on!
Jul 31 '07 #7
jimleon
74
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:
  1. Declare this Function Publically in a Standard Code Module.
    Expand|Select|Wrap|Line Numbers
    1. Public Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
  2. Retrieve the value via the illustrated code below.
    Expand|Select|Wrap|Line Numbers
    1. Dim lngLength As Long, strUserName As String, lngRetVal As Long
    2.  
    3. strUserName = String$(254, 0)
    4. lngLength = 255
    5.  
    6. lngRetVal = GetUserName(strUserName, lngLength)
    7.  
    8. strUserName = Left$(strUserName, lngLength - 1)
    9.  
    10. 'value now contained in strUserName
    11. Debug.Print "The Current Windows User is " & strUserName
OUTPUT:
Expand|Select|Wrap|Line Numbers
  1. The Current Windows User is Armund P
Jul 31 '07 #8
ADezii
8,834 Expert 8TB
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.
  1. Select the Modules Tab in the Database Window.
  2. New.
  3. With (General) visible in the left drop down, and (Declarations) visible in the right drop down, paste the Function Declaration.
Jul 31 '07 #9
ADezii
8,834 Expert 8TB
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 ??
Jul 31 '07 #10

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

Similar topics

1
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...
16
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. ...
3
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...
7
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...
3
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 ***
1
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...
0
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...
4
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...
3
by: Donald Grove | last post by:
Is it possible to append records to a space delimited text file, using Access 2000?
3
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...
1
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...
0
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...
0
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,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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$) { } ...
0
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...
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...

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.