Results 1 to 2 of 2
  1. #1
    2 Star Lounger
    Join Date
    Mar 2001
    Location
    Colorado, USA
    Posts
    144
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Criteria in Domain Aggregate Functions (Access 97)

    We are supporting a legacy Access 97 MDB that has some curious code in it. The following snippet is in the BeforeUpdate event of a form and txt_idx_AG_Bm_Num_Print and txt_AB are textbox fields on the form.

    If DCount("*", "TTT_tbl_Glb_Bm_Detrmn", _
    "[idx_Received] = 'P' AND " & _
    "[idx_AG_Bm_num] = txt_idx_AG_Bm_Num_Print AND " & _
    "[AB] = CDbl(txt_AB)") = 0 Then
    ...
    End If

    Now, if I was writing this code today, I'd do the following:

    If DCount("*", "TTT_tbl_Glb_Bm_Detrmn", _
    "[idx_Received] = 'P' AND " & _
    "[idx_AG_Bm_num] = " & Me!txt_idx_AG_Bm_Num_Print & " AND " & _
    "[AB] = " & CDbl(Me!txt_AB)) = 0 Then
    ...
    End If

    However, much to my surprise, the first code snippet seems to work under the set of circumstances we've been able to test. I would have guessed that it wouldn't make the substitutions for the two fields inside the criteria string.

    My questions are these:
    1) Is there something waiting to bite us if we use the first form of the statement?
    2) Is there a compelling reason to use the second form instead of the first?

    There is a fair amount of bureaucracy associated with changing software so I don't want to change it unless there is a burning need to do so.

    Thanks for the help.

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

    Re: Criteria in Domain Aggregate Functions (Access 97)

    Either form of the statement will work. In expressions in the control source of a form, you can refer to other controls on the form; their values will be substituted automatically. There is no compelling reason to use one or the other form of the statement, so I would leave it as it is.

Posting Permissions

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