Duncs
03-08-2010, 02:47 PM
I posted for some help on a related problem last week, but I've now got something else I need to do.
I've created a table tblUsers with the following fields:
ID - Autonumber
ComputerID - Text
LogonID - Text
DateIn - Date/Time
DateOut - Date/Time
What I need to do is when a user opens the database, insert into the table their ComputerID & LogonID as well as the date/time that they opened the database. Then, when they are finished, it should update the appropriate record with the date/time they closed the database.
In the form open event, I've put the following:
Dim strSQL as String
strSQL = "INSERT INTO tblUsers (DateIn, ComputerID, LogonID) VALUES #" & Now() & "#, '" & Environ("computername") & "', '" & Environ("username") & "';"
docmd.runsql strSQL
This is giving me an error, saying that there is a syntax error in the INSERT INTO statement. I can't see what is wrong, unless I'm missing something glaringly obvious.
Also, what I don't know how to do is then tie this information up to the close event, so that when the user closes the form, and so the database, it will update their login record with the date/time they closed it.
Anyone help?
Many TIA
Duncs
I've created a table tblUsers with the following fields:
ID - Autonumber
ComputerID - Text
LogonID - Text
DateIn - Date/Time
DateOut - Date/Time
What I need to do is when a user opens the database, insert into the table their ComputerID & LogonID as well as the date/time that they opened the database. Then, when they are finished, it should update the appropriate record with the date/time they closed the database.
In the form open event, I've put the following:
Dim strSQL as String
strSQL = "INSERT INTO tblUsers (DateIn, ComputerID, LogonID) VALUES #" & Now() & "#, '" & Environ("computername") & "', '" & Environ("username") & "';"
docmd.runsql strSQL
This is giving me an error, saying that there is a syntax error in the INSERT INTO statement. I can't see what is wrong, unless I'm missing something glaringly obvious.
Also, what I don't know how to do is then tie this information up to the close event, so that when the user closes the form, and so the database, it will update their login record with the date/time they closed it.
Anyone help?
Many TIA
Duncs