Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    Sep 2003
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    DCount() function can't find fields (2002 SP3)

    I am having problems with the following statement:

    Count Off-Days: DCount("[tblNonWorkdays]![Non Work Day]","tblNonWorkdays"," [tblNonWorkdays]![Non Work Day] >= [Date Rec'd] and [tblNonWorkdays]![Non Work Day]<= [Date Completed]")

    Access cannot find [Date Rec'd] and/or [Date Completed] fields in the "where portion" of the function statement.

    I have added prefix for the table [tblQuotes]! and the query [qryListAllQuotes]! separately, but no help.

    Have I missed something ? <img src=/S/confused3.gif border=0 alt=confused3 width=45 height=45>


    Also, the builder window doesn't seem to support word wrapping for long arguments. Is this functionality still supported ?

    Any help is apreciated.

    CMC

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: DCount() function can't find fields (2002 SP3)

    DCount doesn't recognize them because they are inside the quotes. Try this:

    Count Off-Days: DCount("[Non Work Day]","tblNonWorkdays","[Non Work Day] >= " & [Date Rec'd] & " AND [Non Work Day] <= " & [Date Completed])

    The Expression Builder does not support word wrap, but you can press Enter to start a new line. The Zoom window (Shift+F2) does do word wrapping.

  3. #3
    New Lounger
    Join Date
    Sep 2003
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: DCount() function can't find fields (2002 SP3)

    Thanks HansV -

    You got me started on the right path. Took me many more hours to get the syntax exactly right.

    I started by using literal date constants to test the logic as below:

    Off-Days: DCount("[tblNonWorkdays]![Non Work Day]","tblNonWorkdays"," [tblNonWorkdays]![Non Work Day] Between #7/6/2004# And #7/13/2004#")


    The final statement (that worked) is this:

    Count Off-Days: DCount("[tblNonWorkdays]![Non Work Day]","tblNonWorkdays"," [tblNonWorkdays]![Non Work Day] > " & "#" & [Date Recd] & "#" & " And" & "[tblNonWorkdays]![Non Work Day] <=" & " #" & [Date Completed] & "#")

    Determining what needed to be enclosed in "", and what did not, was the biggest obstacle. Not much mention of this in the help screens.

    Thanks for your help!

    CMC

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •