Hopefully I posted this in the right forum. (This is my first time actually posting
I have a form for account tracking info. Users add new records and edit existing ones. I want to have a table (called LOG) that logs each time a user clicks on the edit (or add) button. After trying every single code sample on INSERT INTO that I could fine here, I finally got one thing to work:
CurrentDb.Execute "INSERT INTO LOG ([Timestamp]) values ('" & Now() & "');"
I also have a User field in the log table that has a default value of =Environ("Username", which pulls the windows logon name and inserts it into the User field.
So right now, the log table is giving me the time a user hit the edit button (the code's in the edit sub) and the windows logon name for the user.
My problem is that I would also like it to record just the simple words "Add" or "Edit" in the third field of the log table (Activity), depending on where the code is, of course.
I have tried every combination of quation marks, commas, parenthese, etc, and just cannot find the correct syntax. Only once did I get the code to where I did not get an error, and that was with:
CurrentDb.Execute "INSERT INTO LOG ([Timestamp, [Activity]]) values ('" & Now() & "', '" & Edit & "');"
But that put NOTHING in the log table!! No error, but also no fields filled in!!
I have tried MS Access help, and using the syntax they use in their code samples got me absolutely nowhere. I've searched numerous times here, also. Still no dice.
Someone please help me, if I see one more syntax error, I'm going to snap. This is the absolute last piece of code to figure out before I can roll this thing out. Sorry this was so long. Thank you!!
Amanda
I have a form for account tracking info. Users add new records and edit existing ones. I want to have a table (called LOG) that logs each time a user clicks on the edit (or add) button. After trying every single code sample on INSERT INTO that I could fine here, I finally got one thing to work:
CurrentDb.Execute "INSERT INTO LOG ([Timestamp]) values ('" & Now() & "');"
I also have a User field in the log table that has a default value of =Environ("Username", which pulls the windows logon name and inserts it into the User field.
So right now, the log table is giving me the time a user hit the edit button (the code's in the edit sub) and the windows logon name for the user.
My problem is that I would also like it to record just the simple words "Add" or "Edit" in the third field of the log table (Activity), depending on where the code is, of course.
I have tried every combination of quation marks, commas, parenthese, etc, and just cannot find the correct syntax. Only once did I get the code to where I did not get an error, and that was with:
CurrentDb.Execute "INSERT INTO LOG ([Timestamp, [Activity]]) values ('" & Now() & "', '" & Edit & "');"
But that put NOTHING in the log table!! No error, but also no fields filled in!!
I have tried MS Access help, and using the syntax they use in their code samples got me absolutely nowhere. I've searched numerous times here, also. Still no dice.
Someone please help me, if I see one more syntax error, I'm going to snap. This is the absolute last piece of code to figure out before I can roll this thing out. Sorry this was so long. Thank you!!
Amanda