Help with Code - Random Selection

  • Thread starter angelinarose via AccessMonster.com
  • Start date
A

angelinarose via AccessMonster.com

Hi All,
I am having a little trouble with some code that I'm working on. I have a
database that has a table called tblEmployees. In the table it has the
employee ID, employees name, Unit name, Selected which is a Yes/No-checkmark
field, Selected Date. I'm trying to take this table and do a Random Selection
of employees. I want the user to select how many employees they want to
select and then pick randomly from the table. I have that part done. However
I'm having problems with the fact that I want it to select everyone in the
table once and then reset the table based on the selected field. What I need
it to do is check the table to see if everyone has been selected and then
clear out the table if everyone has. I think it will be an IF Then Else
statement, however I have tried several things and can't get it to work. Can
someone please assist me with this? Thanks
 
J

Jack Leach

You can use Dlookup (or Elookup from Allen Browne), and try to pull the first
record it finds that's selected. If it returns null, you know that at least
one record is selected and you can clear it from there. Or, if you are
trying to find out if ALL records are selected, you can use the lookup
function to pull the first value that equals No, and if it returns null you
know you have all of your reclrds selected.


If IsNull(ELookup("Selected", "tblEmployees", "[Selected] = No") Then
Call SubToClearTable
End If


hth
--
Jack Leach
www.tristatemachine.com

"I haven't failed, I've found ten thousand ways that don't work."
-Thomas Edison (1847-1931)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top