Results 1 to 3 of 3
  1. #1
    4 Star Lounger
    Join Date
    Sep 2002
    Location
    Stafford, Staffordshire, England
    Posts
    585
    Thanks
    0
    Thanked 0 Times in 0 Posts

    DCount: Criteria based on a cbo value (xp)

    I've tried to search for a solution but have been unable to find the correct syntax.

    I have a textbox which displays the number of records in a table based on the criteria "Chemistry" using this expression as the control source :

    =DCount("[SubjectID]","[tblOrder]","SubjectID = 'Chemistry'")

    I want to use the value in a combobox as the criteria but I cannot get the correct syntax. The cbo is on the same form and is named "cboSubjectID".

    TIA
    <font color=blue><font face="Script MT Bold"><big>Rob</big></font face=script></font color=blue>

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

    Re: DCount: Criteria based on a cbo value (xp)

    Hi Rob,

    Try this:

    I've tried to search for a solution but have been unable to find the correct syntax.

    =DCount("[SubjectID]","[tblOrder]","SubjectID = " & Chr(34) & [cboSubjectID] & Chr(34))

    This assumes that SubjectID is a text field. The Chr(34)s are double quotes ".

  3. #3
    4 Star Lounger
    Join Date
    Sep 2002
    Location
    Stafford, Staffordshire, England
    Posts
    585
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: DCount: Criteria based on a cbo value (xp)

    Hi Hans

    Sorry about the delay in responding but I was called away immediately after posting.
    Your solution is perfect as ever. I'm sure I tried the same myself but it produced errors but I've just figured out why that was - typo in control name.

    Thanks
    <font color=blue><font face="Script MT Bold"><big>Rob</big></font face=script></font color=blue>

Posting Permissions

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