The simplest solution is a three step process
1) retrieve userid (SELECT UserID FROM tblUser WHERE UserName="@USERID")
2) retreive computerid (SELECT ComputerID FROM tblComputer WHERE computerName="@WKSTA")
3) insert into lookup table (INSERT INTO tblLoginLog VALUES(UserID,ComputerID,LoginTime) SET (UserId,ComputerId,@TIME)

Be advised that this is only the framework.

Also, you might want to use the DB... UDFs that are posted in the UDF Forum, this will make coding database connectivity much easier.

The SQL statements can be compacted into a single lien, though. However, the outline above is easier to understand.
_________________________
There are two types of vessels, submarines and targets.