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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding data to table with code

Status
Not open for further replies.

puforee

Technical User
Oct 6, 2006
741
US
I have some code, that I got from one of these forums, that will return the userID of the person logged in to my DB. I want to create a log (withing a table) that contains the UserID, Time/Date and store it in a new record in the table. In VB how to I add data to a table in a new record.

So, when a user logs on.... the code would put their userID and date/time into two fields in the table.

Thanks,
 
Code:
CurrentDb.Execute "INSERT INTO [your table] ([user ID field],[Date/time field])" _
 & " VALUES ('" & userIDvariable & "',#" & Now & "#)"

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks,

I will give this a try.

Thanks very much.
 
PHV,

I am trying your code and getting partial success...can you help a little more.

Fileds I need to store

UseID field from generated by Function...variable fOSUserName

Date/Time filed..I think your code shows this

Name field...I this will be a changing varriable depending on what button is pushed and will equal the button label.

Finally, can your code be part of the UserID Function...this contains API calls for userID. Or should it be seperate code that is run when I click a button.

Thanks,
 
OH, and one thing I forgot. The UserID field and the Name fields are formatted text. Of course the Date/Time filed is formatted for date and time.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top