Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Call function fOSUserName into Query 1

Status
Not open for further replies.

Steven547

Technical User
Sep 15, 2004
165
US
I have a function: fOSUserName
This grabs the current user name. I want to store that username in a table along with the date, so I know immediately, who is in the database incase I have to have them log out. And when they log out, the table should be updated with the date and time of logging out as well.

I'm not that good with writing "SQL" code for appends in VBA, so i was going to start with a query. Obviously it would have to be an append query, but how would I call that function: fOSUserName to the query or how would you recommend going about this?

thanks.
 
Provided that fOSUserName is a public function in a standard code module:
INSERT INTO yourTable (usrName,sysDate,typLogging)
VALUES (fOSUserName(),Now(),'IN')

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Let me see if I understand this:

INSERT INTO yourTable (usrName,sysDate,typLogging)
VALUES (fOSUserName(),Now(),'IN')

yourTable: My table name obviously.

usrName,sysDate,typLogging): These are the field names in my table?

VALUES (fOSUserName(),Now(),'IN'):
fOSUserName: the user name
Now(): the current date

'IN': What would this be? Oh wait, would that be the "switch" that the user is "IN" (as opposed to "out") the system...

 
OK..Update:

It doesn't seem to be updating my table...This is what I have:

Dim strSQL As String

strSQL = "insert into tblUsers(UserName,StartDate) Values (fOSUserName(), Now())"


(sorry, I'm still new to the DIM, etc)

 
Add the following line:
DoCmd.RunSQL strSQL

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I guess that would be the same as what I did. I wound up creating a query based on the "insert into". And on load of the form, I just docmd and run that query. So far so good. I'll have to look into the above suggestion. Would probably be more "convenient".
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top