Auto check box

  • Thread starter Thread starter ladybug via AccessMonster.com
  • Start date Start date
L

ladybug via AccessMonster.com

I have two text boxes. Once for a begin date and one for an end date. I
then have a Yes/No field. I want the Yes/No field to be Yes(True) if the end
date is not entered. Does anyone have a code that will make this work?

Thank you
 
Are you saying that every record without an end date would also have a
Yes/No field set to Yes? Or with an end date would have it set to No?

If so, don't bother to add a field for this. On the form, in the AfterUpdate
event for the end-date control, Instead, "calculate" a Yes or No, based on
whether there's an end date, and set the value of your (unbound) Yes/No box
appropriately.

Your expression might look something like (your actual syntax may vary):

Me.txtYesNo = (Nz(Me.txtDate,"")="")

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
I don't need the check box on the form. I will try to explain better...
The piece that I am working on is to track Leave of Absence by employee.
When an employee is on a Leave of Absence the Database user will need to go
in to the form to select the type of Leave and then type in the Start Date.
Once the employee returns they will enter an end date. Employees may have
multiple leaves of absence throughout their employment.
I am creating a query that incorporates this data as well as other additional
info. I am creating this query for a report. I want the query/report to be
calculating some type of checkbox or determination whether they are on a
Leave of Absence or not.
So when a user runs the report, and the employee is currently on a Leave of
Absence (no end date), the report will say "yes" or check mark to signify the
Leave of Absence. If all Leaves of Absences for that employee have end dates
then it will say "no" or no check mark.
I hope I have explained myself clearly. Is this possible? If not, any
suggestions would be greatly appreciated. Thank you!
 
It sounds to me like you could use a query against the underlying table.
Add a field to the query that "calculates" a "Yes" or a "No", based on the
presence of a date in the EndDate field. You could use an IIF() function to
do this, something like:

IIF(IsDate([LOAEndDate]) = True,"No","Yes")

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
Your suggestion does work. However, I now have another problem. If an
employee was never on a Leave of Absence they are not showing up at all. I
changed the property for the relationship, but then everybody is a YES no
matter if they are on a Leave or not. How can I show every employee and
have a Yes if there is no end date, but a no if they have never been on a
Leave?

Thank you so much for your help. I am learning as I go....I would be so lost
without this website!

Jeff said:
It sounds to me like you could use a query against the underlying table.
Add a field to the query that "calculates" a "Yes" or a "No", based on the
presence of a date in the EndDate field. You could use an IIF() function to
do this, something like:

IIF(IsDate([LOAEndDate]) = True,"No","Yes")

Regards

Jeff Boyce
Microsoft Office/Access MVP
I don't need the check box on the form. I will try to explain better...
The piece that I am working on is to track Leave of Absence by employee.
[quoted text clipped - 47 lines]
 
Back
Top