clear a label based on no record

chewy

SuperNintendo Chalmers
Local time
Today, 17:54
Joined
Mar 8, 2002
Messages
581
I have a label that displayes the count of how many vacations someone has taken. However if they have no vacations taken I want it to be cleared. Currently it keeps it in there even if it has no current records. Take a look at the DB. It is in frmMain, choose Vacation and some people...you will see some have no vacations and some do. But I just want it cleared but cant figure out the what if statement to compare
 

Attachments

chewy,

In the lstEmployee_Click event, before
the requery:

Use DCount to see if any records will
be retrieved by your query.

If > 0 Then
Forms![frmMain]![qryEmployee subform1]![EmployeeID Label].Visible = True
Forms![frmMain]![qryEmployee subform1]![ReasonID Label].Visible = True
Forms![frmMain]![qryEmployee subform1]![Day Label].Visible = True
Forms![frmMain]![qryEmployee subform1]![TotalDays Label].Visible = True
Else
Forms![frmMain]![qryEmployee subform1]![EmployeeID Label].Visible = False
Forms![frmMain]![qryEmployee subform1]![ReasonID Label].Visible = False
Forms![frmMain]![qryEmployee subform1]![Day Label].Visible = False
Forms![frmMain]![qryEmployee subform1]![TotalDays Label].Visible = False
End If

Then Requery.

I didn't try it, but that should work.

Wayne
 
im sorry. Still not clear on the dcount
 
chewy,

From Help:

=DCount("[OrderID]", "Orders", "[ShipRegion] = 'CA'")

I put these on separate lines to make it easier to
read:

NumRecs = DCount("[tblVacation],
"[Employee]",
"EmployeeID = " & [Forms]![frmMain]![lstEmployee] & " And " & _
"ReasonID = " & [Forms]![frmMain]![lstReason])

If NumRecs > 0 Then

Else

End If

Wayne
 

Users who are viewing this thread

Back
Top Bottom