Since your ID field is text you need to use the appropriate quote delimiters.
Modify the DCount line like this;
If DCount("ID", "tblProjectTasks", "ProjectID = '" & rst!ProjectID & "'") >
for clarity it's
If DCount("ID", "tblProjectTasks", "ProjectID = ' " & rst!ProjectID " ' ") >
but don't put spaces between the quotes.
In addition, you don't need and really shouldn't use a field name in the
DCount function. The better way is:
DCount("*", "tblProjectTasks", "ProjectID = """ & rst!ProjectID & """")
Note the change in quote marks. It is 3 doubles before and two doubles
after. In probably is not an issue in this case, but if any record has an
apostrephe in the field, it will throw an error. It seems daunting at first,
but here is how to easily figure it out.
First, to include a " in a string in VBA, use two qoutes ""
So, in the original version:
DCount("*", "tblProjectTasks", "ProjectID = '" & rst!ProjectID & "'")
Single Quotes ^
^
So replace one single ' with two doubles "" It then becomes
DCount("ID", "tblProjectTasks", "ProjectID = """ & rst!ProjectID & """")
That's the way I have taught myself because I can never get it right the
first time, so I write it with the single qoutes then go back and replace a
single with two doubles.

Signature
Dave Hargis, Microsoft Access MVP
> Since your ID field is text you need to use the appropriate quote delimiters.
> Modify the DCount line like this;
[quoted text clipped - 40 lines]
> >
> > All help is appreciated.
Beetle - 19 Mar 2008 19:47 GMT
You're right about the double quotes Dave. I usually don't get it right the
first
time either, so that's a good tip about replacing a single with two doubles.
That's the first time I've heard that you shouldn't use a field name in the
DCount function. Any specific reason, or is it just to eliminate the chance
of having a mis-spelled field name, etc.?

Signature
_________
Sean Bailey
> In addition, you don't need and really shouldn't use a field name in the
> DCount function. The better way is:
[quoted text clipped - 64 lines]
> > >
> > > All help is appreciated.