Use code to determine if a record is on a query or not

velcrowe

Registered User.
Local time
Today, 09:11
Joined
Apr 26, 2006
Messages
86
I have a form that shows employee license information. I also have a query & form based on that query to show licenses currently suspended. I would like to on my employees form to flash "license suspended" label if their name/record id is on the license suspension query. For all employees whose license isn't suspensed I would don't want anything to show. I can get the label to flash and to appear. I just need help evaluating the query and comparing it to the current record. Example I

if me.id = queryname.id then....execute label flashing, etc.

Can I write code to do this? Thank you
 
One way would be a DCount:

If DCount(...) > 0 Then
 
I have used the dcount before but in this case I need to see if I am looking at employee id #5 on the employee form, the label flashing would be an indication that employee id#5 is on the license suspension table. Is there a way to determine that it's on the query? Thanks again
 
As Paul said, you can use the DCount Function on your forms Current Event to check for the record in your query and flash the label.
 
Here's a good reference:

http://www.mvps.org/access/general/gen0018.htm

You want to use the suspension query/table as the source, and use the id from the form in the criteria. That would basically say "is the person on this form present in the suspension table?"
 

Users who are viewing this thread

Back
Top Bottom