Click to See Complete Forum and Search --> : Make a record with VB or a macro(Access 2002)


shamus
October 28th, 2004, 02:55 PM
Does anyone know how to create a record in a table with a macro or VB? I need to record the CurrenUser() in a table @ startup using the AutoExec. Or a hidden form op.?

Thanks

shamus
November 2nd, 2004, 08:17 AM
Well, I fixed my own problem in a roundabout way. When a user logs in, I used an UPDATE query to record CurrentUser() and Now() in one table, then an APPEND query to copy the new record to a "userlog" table. Works fine regardless of how many users are logged on. BUT, I quess an ERROR is possible.

JeffB
November 6th, 2004, 01:02 AM
In case you want to know how to code it, here is how to do it (use the Macro to run the code):

Public Function StartUp() As Long
CurrentDb.Execute "INSERT INTO UserLog([Name], [Date]) VALUES('" & _
CurrentUser & "','" & Now() & "')"
End Function

Your system might create an error if two or more users enter at the same time.

JeffB