L
Leslie
I am trying to compare a date within a recordset. I have changed this code
around several different ways and my field ("DateSelected") in the recordset
is always null even though I know it's not. Any help on this is
appreciated.....below is a chunk of my code:
'Select Employees eligible for random selection
Set MyRS = MyDB.OpenRecordset("SELECT tblEmployeesx.ID,
tblEmployeesx.FullName, tblEmployeesx.RandomSelected, " & _
"tblEmployeesx.Type, tblEmployeesx.DateSelected FROM tblEmployeesx WHERE
(((tblEmployeesx.RandomSelected)=False)) AND ((tblEmployees.Type =
'Employee'));")
'Select random employee
If (MyRS.EOF Or MyRS.BOF) <> True Then
MyRS.MoveLast
NumOfRecords = MyRS.RecordCount
SpecificRecord = Int(NumOfRecords * Rnd)
If SpecificRecord = NumOfRecords Then
SpecificRecord = SpecificRecord - 1
End If
MyRS.MoveFirst
For i = 1 To SpecificRecord
If MyRS.Fields("DateSelected").Value = datSelected Then
MsgBox "Someone has already been selected for that date. Please
try again."
FindRandom = "Try Again"
Exit Function
End If
MyRS.MoveNext
Next i
around several different ways and my field ("DateSelected") in the recordset
is always null even though I know it's not. Any help on this is
appreciated.....below is a chunk of my code:
'Select Employees eligible for random selection
Set MyRS = MyDB.OpenRecordset("SELECT tblEmployeesx.ID,
tblEmployeesx.FullName, tblEmployeesx.RandomSelected, " & _
"tblEmployeesx.Type, tblEmployeesx.DateSelected FROM tblEmployeesx WHERE
(((tblEmployeesx.RandomSelected)=False)) AND ((tblEmployees.Type =
'Employee'));")
'Select random employee
If (MyRS.EOF Or MyRS.BOF) <> True Then
MyRS.MoveLast
NumOfRecords = MyRS.RecordCount
SpecificRecord = Int(NumOfRecords * Rnd)
If SpecificRecord = NumOfRecords Then
SpecificRecord = SpecificRecord - 1
End If
MyRS.MoveFirst
For i = 1 To SpecificRecord
If MyRS.Fields("DateSelected").Value = datSelected Then
MsgBox "Someone has already been selected for that date. Please
try again."
FindRandom = "Try Again"
Exit Function
End If
MyRS.MoveNext
Next i