Dlookup Criteria Problem

  • Thread starter Thread starter Taffy-Taff
  • Start date Start date
T

Taffy-Taff

Hi -
I am having a problem with DLookup. I have a table with a field calle
COMMENTS. This field is a text field. A record might have ht
following information under this field: "Called person on 06/11/2004".
Each record in the table has information under the COMMENTS field an
each information contains a date. I have a text box on a form and i
ask user to input a date. I want the computer to tell me how man
records in the database has that date as a part of the comment. I us
the following command and it works perfectly:

intX = DCount("[cust code]", "outside", "[comments] like '*6/11/2004*
AND [A/R Rep] = 'Barbara'")

However, instead of typing the date, I want the computer to take th
date from the text box (txtDate) on the form. When I run the statemen
above, I get IntX=24. I want to modify the statement so that it take
the date from the form but still give the 24 as the response. I wa
thinking about using the following but I got error:

intX = DCount("[cust code]", "outside", "[comments] like '*
&Forms!frmEmployes![txtStartDate]&*' AND [A/R Rep] = 'Barbara'")


Can you kindly tell me how to get this done
 
You're very close! You need to have the form's control reference outside the
string and you need spaces on either side of the & character.

intX = DCount("[cust code]", "outside", "[comments] like '*" &
CStr(Forms!frmEmployes![txtStartDate]) & "*' AND [A/R Rep] = 'Barbara'")
 
Back
Top