Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Nov 2001
    Location
    Brisbane, Queensland, Australia
    Posts
    330
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Dsum Criteria (Acc 97 sr2 on 95b)

    I have a Dsum expression that has criteria that points to a list of names:

    Dim varItm
    Dim empname
    For Each varItm In lstEmployees.ItemsSelected
    empname = lstEmployees.ItemData(varItm)
    txtCurrentHours = DSum("[Hours]", "tblJobAllocate", "[Employee] = " & empname)
    Next varItm

    With this, empname = "BELCHER Allan" and when I run it, I get the following error:

    Syntax error (missing operator) in query expression '[Employee] = BELCHER Allan'

    How should it be written?
    "Heading for the deep end"

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Dsum Criteria (Acc 97 sr2 on 95b)

    It's objecting to the space in the name since it doesn't realize the whole thing is a string. Try this instead:

    <pre>txtCurrentHours = DSum("[Hours]", "tblJobAllocate", "[Employee] = '" & empname & "'")</pre>

    Charlotte

  3. #3
    3 Star Lounger
    Join Date
    Nov 2001
    Location
    Brisbane, Queensland, Australia
    Posts
    330
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Re: Dsum Criteria (Acc 97 sr2 on 95b)

    Once again, thank you very much for your quick clear answer to my problem.
    "Heading for the deep end"

Posting Permissions

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