multiple criteria Dsum with subform reference

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • zedtedio
    New Member
    • Jan 2013
    • 1

    multiple criteria Dsum with subform reference

    Hi there
    Can anyone help me on this.
    I'm trying to Dsum with 2 criterias.
    It retrieves an '2450' run-time error " can't find 'sf_especificac oes'.
    thx


    Code:
    t_cma_pr_calc = DSum("[t_esp_consumo]*[t_mat_pr_in]/[t_uni_factor]", "q_especificacoes", "[t_esp_t_cma_id] = " & Modelo & "AND forms!sf_especificacoes!t_mgr_uppers=-1")
    Last edited by Rabbit; Jan 9 '13, 05:43 PM. Reason: Please use code tags when posting code.
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    Please use code tags when posting code.

    1) You probably need a space before the AND.
    2) Domain aggregate functions don't have access to the Forms collection.
    3) You don't need to. Just do the check in your code before hand.

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32653

      #3
      Originally posted by Rabbit
      Rabbit:
      2) Domain aggregate functions don't have access to the Forms collection.
      I'm not sure that's true (I may be wrong of course). I believe the error message indicates the specified form is either misspelled or simply not open at that point.
      Point #3 is always a good idea anyway ;-)

      I usually advise working out the criteria beforehand in a string variable anyway, as well as to use a template form of the criteria to start with and fill in the variable parts using Replace(). That way it is much easier to see what you're doing.

      In this case, the value of Forms!sf_especi ficacoes!t_mgr_ uppers=-1 can be worked out beforehand so it's unclear why you would think you needed to include it in the DSum() call. Handling that sensibly stops all the confusion anyway it seems.

      Comment

      Working...