Results 1 to 2 of 2

Thread: DSum Critreria

  1. #1
    Join Date
    Nov 2003

    Unanswered: DSum Critreria


    I have the following in my form:

    Dim varselected As Variant
    Dim strSQL As String
    For Each varselected In Me.programvalue.ItemsSelected
    strSQL = strSQL & "'" & Me.programvalue.ItemData
    (varselected) & "',"
    Next varselected
    If strSQL <> "" Then
    strSQL = "[obligation] IN (" & Left(strSQL, Len
    (strSQL) - 0) & ")"

    With CodeContextObject
    Me.looktest = DSum("Allocation", "Program",

    End With

    When I added the following, I get an error that says that
    the object doesn't contain the Automation object 'strSQL':

    Me.looktest2 = Nz(DSum
    ("[VouchAmt]", "FY02_BASETABLE", "strSQL and datepart('m',
    [Start Date])= 10 and [FY] = [forms]![password]![FY]"), 0)

    I suppose it has something to do with the additional
    criteria along with the strSQL. How can I resolve this?
    Is my syntax wrong? Because Me.looktest = DSum
    ("Allocation", "Program", strSQL) works. But in this
    case the DSum is much more complex.

    Teresely, I want to add the dynamic strSQL filter to the DSum criteria. What is the best way to do this?

    Thanks in advance,

  2. #2
    Join Date
    Mar 2003
    The Bottom of The Barrel
    Provided Answers: 1
    I think you're passing the literal string strSQL instead of the var... try:

    Me.looktest2 = Nz(DSum
    ("[VouchAmt]", "FY02_BASETABLE", strSQL & "and datepart('m',
    [Start Date])= 10 and [FY] = [forms]![password]![FY]"), 0)

Posting Permissions

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