PDA

Click to See Complete Forum and Search --> : Database access


SimonPearce
Mar 8th, 2000, 06:24 PM
I'm using this code to write who's logged onto a workstation to a databse. When they log off, it records "Logged off".

The problem is, it leaves the old record and when it writes the new one, it missed the username and puts "Logged off" on a record of it's own :(

Any ideas?

Simon

Private Sub Form_Unload(Cancel As Integer)

'write to Who's On file
Dim dbs As Database, rstwhosOn As Recordset
Set dbs = OpenDatabase("user.mdb")
Set rstwhosOn = dbs.OpenRecordset("whosOn")

rstwhosOn.MoveFirst

Do Until rstwhosOn.EOF
If rstwhosOn!workstationName = CurrentComputername Then
rstwhosOn.Delete
End If
rstwhosOn.MoveNext

Loop

rstwhosOn.AddNew
rstwhosOn!workstationName = CurrentComputername
rstwhosOn!UserName = "Logged off"
rstwhosOn.Update

rstwhosOn.Close
dbs.Close

End Sub