Why Doesn't this work?

  • Thread starter Thread starter RobUCSD via AccessMonster.com
  • Start date Start date
R

RobUCSD via AccessMonster.com

With the code below I want the form to allowAddtions if there are no previous
visits (records). qryVisitList is the record source for the sub form
frmVisits. When I go to a patient who has no previous visits, the form comes
up blank. I use this same code on the same form for a different purpose and
it works fine. Its in the current event.

Your help is greatly appreciated. Rob

If (DCount("*", "[qryVisitList]") < 1) Then
Me.Form.AllowAdditions = True
Else
Me.Form.AllowAdditions = False
End If
 
Hi Rob

First, Me *is* a Form, so you don't need "Me.Form".

Next, you are counting ALL the records in qryVisitList, not just the ones
that are filtered by the link fields to your main form.

Try this:
Me.AllowAdditions = (Me.RecordsetClone.RecordCount = 0)
 
Graham, this is what I used and it works perfectly. I've been screwing around
with this for longer than i care to admit. Thank you, thank you, thank you. I
really appreciate it.

Have a great forever, Rob
******************************************************************
If (Me.RecordsetClone.RecordCount = 0) Then
Me.AllowAddtions = True
Else
Me.AllowAddtions = False

Graham said:
Hi Rob

First, Me *is* a Form, so you don't need "Me.Form".

Next, you are counting ALL the records in qryVisitList, not just the ones
that are filtered by the link fields to your main form.

Try this:
Me.AllowAdditions = (Me.RecordsetClone.RecordCount = 0)
With the code below I want the form to allowAddtions if there are no
previous
[quoted text clipped - 12 lines]
Me.Form.AllowAdditions = False
End If
 
Back
Top