G
Guest
Can DCount be used to count the records in a table with a particular value in
one of the fields?
I have a form that's bound to my main table. On that form is a cmd button
to open a form that's bound to a related table. When I click the button,
just the records with the pk value in the main form will display in the
second form. What I want is an If statement attached to the current form
event of the main form such that if there are any related records in the
second table (the one bound to the form that opens with the cmd button on the
main form), then I want a color change in a box on the main form.
This is what I tried when my mind was asleep:
If DCount("*", "tblReportLinks") > 0 Then
Me.Box117.BackColor = vbRed
Else
Me.Box117.BackColor = vbBlack
End If
However, that doesn't limit the records to just the ones related to the
record displaying in the main form. How do I limit the records counted to
just those associated with the ID (pk) in the main form? The ID in the main
form is a fk in the form that opens with the command button...
Hope that's understandable.
Thanks,
CW
one of the fields?
I have a form that's bound to my main table. On that form is a cmd button
to open a form that's bound to a related table. When I click the button,
just the records with the pk value in the main form will display in the
second form. What I want is an If statement attached to the current form
event of the main form such that if there are any related records in the
second table (the one bound to the form that opens with the cmd button on the
main form), then I want a color change in a box on the main form.
This is what I tried when my mind was asleep:
If DCount("*", "tblReportLinks") > 0 Then
Me.Box117.BackColor = vbRed
Else
Me.Box117.BackColor = vbBlack
End If
However, that doesn't limit the records to just the ones related to the
record displaying in the main form. How do I limit the records counted to
just those associated with the ID (pk) in the main form? The ID in the main
form is a fk in the form that opens with the command button...
Hope that's understandable.
Thanks,
CW