1

I am using a DCOUNT function to look at a table in access and see if a record exists - if it does then return a yes value.

=IIf(DCount("*","COMMENTS","[PROJECTID] = " & [PROJECTID])>0,"YES","")

This works great if my ProjectID is all numeric values - I only get #Error on the alphanumeric values.

I know that I have to make the ProjectID criteria a string but am having trouble placing the quotes.

Gord Thompson
  • 116,920
  • 32
  • 215
  • 418
Ethan V
  • 51
  • 1
  • 5

1 Answers1

1

First, break out the DCount piece and work on that by itself.

It sounds like your COMMENTS.PROJECTID field is text datatype, so add quotes before and after the value you concatenate into the third DCount argument (Criteria):

DCount("*", "COMMENTS", "[PROJECTID] = '" & [PROJECTID] & "'")

After you have that piece working correctly, add it into your IIf() function.

HansUp
  • 95,961
  • 11
  • 77
  • 135
  • Thanks HansUp - that led me in the right direction `=IIf(DCount("*","COMMENTS","[ProjectID] = '" & [ProjectID] & "'")>0,"YES","")` ended up being what used – Ethan V Apr 30 '15 at 20:00