spacepro
Registered User.
- Local time
- Today, 11:19
- Joined
- Jan 13, 2003
- Messages
- 715
Hi All,
I currently have a multiselect listbox which shows all Employees and there relevant department from tblEmployees.
For Each Employee that is selected I want to add a record to log the time in and out to tblTime.
But I want to look up the table tbltime to ensure they haven't already logged in today. Currently I am using the following code, but this does not include the validation.
The problem is that even the code selects the selected items it will only select the one that was clicked on.
Thanks
Andy
I currently have a multiselect listbox which shows all Employees and there relevant department from tblEmployees.
For Each Employee that is selected I want to add a record to log the time in and out to tblTime.
But I want to look up the table tbltime to ensure they haven't already logged in today. Currently I am using the following code, but this does not include the validation.
Code:
Private Sub CmdLogin_Click()
Dim myFrm As Form, myCtl As Control
Dim item As Variant
Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenRecordset("tblTime", dbOpenDynaset)
Set myFrm = Me
Set myCtl = Me.Lbxemployee
With rst
For Each item In myCtl.ItemsSelected
.AddNew
.Fields("Employee") = Me.Lbxemployee.Column(1)
.Fields("Department") = Me.Lbxemployee.Column(2)
.Fields("DateIn") = Date
.Fields("TimeIn") = Time
.Fields("EnteredBy") = Me.Text6
.Update
MsgBox "Logged In", vbInformation, "OK.."
Next item
End With
Set rst = Nothing
End Sub
Thanks
Andy