Easy date/userid function ? for experts (I think) (1 Viewer)

mitchem1

Registered User.
Local time
Today, 05:46
Joined
Feb 21, 2002
Messages
153
The database on which I am working allows the user to search for a project using a simple form. The retrieved project is then displayed on a separate form along with a subform that displays any comment(s) associated with the project. The user will be able to enter a new comment via the subform. Can someone tell me how to capture the User ID and Date of the new comment. I have read about the Now() and fOUserName() functions but am unsure where to put them and how to call them. Thank you very much.
 

jatfill

Registered User.
Local time
Today, 06:46
Joined
Jun 4, 2001
Messages
150
The fastest method would be to create two fields in the table that holds the note, 'createdon' and 'createdby' (or whatever anems you like), then set the fields'default values using the two respective functions you already have. This makes capturing the data transparent to the user & prevents people from modifying who/when (if that is your intention).
 

mitchem1

Registered User.
Local time
Today, 05:46
Joined
Feb 21, 2002
Messages
153
Thanks for the reply, but please note that my original post stated that I had only read about the functions. I am looking for help on where to put them and how to call them.
 

David R

I know a few things...
Local time
Today, 05:46
Joined
Oct 23, 2001
Messages
2,633
Check the archives

This question has been asked many times in the past, which is probably where you read about it. Check the archives of this forum for ways to use them.

You'll usually get a faster response by doing your own search first, then asking specific questions you're having trouble with, rather than expecting someone to code your application for you.

Plus, you'll learn more along the way. Don't get discouraged; post back if you get stuck on some part of it.
 

mitchem1

Registered User.
Local time
Today, 05:46
Joined
Feb 21, 2002
Messages
153
David R,

Not sure what I did to warrant that response. I realize there are many articles on this topic in the forum; believe me, I think I've read most of them.
However, I am fairly new to Access and very new to VB. I simply don't know or understand where to place the mentioned functions and what events to call them from. I strongly disagree that the questions I asked are "expecting someone to code the application for me". I put a lot of time in before I made the original post.
 

David R

I know a few things...
Local time
Today, 05:46
Joined
Oct 23, 2001
Messages
2,633
Then I suppose I am confused on what you are asking.

If you're unfamiliar with VBA code, someone can help you step through the process. I'm going to guess that you've got copies of the functions themselves (fOSUserName() is a function you have to put in a global module, Now() comes ready-made in Access).

Let me try this again without the unintended venom.

Open a new module in Access. Paste in the code that you've got for fOSUserName() as a new function. (If you don't have it, look here: http://www.access-programmers.co.uk/forums/showthread.php?s=&threadid=7799 ). Save the module (it doesn't matter what you call it; the function name is what's important.

Is the Comment field a memo that you want to be able to add to the bottom of? Or (as it sounds) is it a text field that can have more than one entry per record? It sounds like you have a continuous subform that records comments, and you want to have the username and date/time stored in additional fields. That's a little easier than adding to a memo field, so I'll hope for the best and go for that.

In your subform fields (the controls for displaying username and date/time), go to the Data tab of Properties and look for a property called Default Value.
For the date/time field, it should be =Now(). For the username field, it should be =fOSUserName() (or whatever you called your function). You can even make these fields invisible (Properties>Format>Visible: No), or at the least set Locked: Yes and/or Enabled: No so your users can't mess with your audit trail.

As for my initial response, all I can say is this:
Never attribute to malice that which can be adequately explained by stupidity. Never attribute to stupidity that which can be adequately explained by poor communication. Always assume communication failure, even if it looks unlikely. (Elasait’s corollary to Hanlon’s razor)
 

mitchem1

Registered User.
Local time
Today, 05:46
Joined
Feb 21, 2002
Messages
153
After rereading this thread, I believe I probably overreacted. I apologize for that and want to thank you for taking the time to spell out what I need to do. I will give it a shot and see what I come up with. Thanks again.
 

Users who are viewing this thread

Top Bottom