Results 1 to 4 of 4
  1. #1
    lefty2cox is offline Competent Performer
    Windows 7 64bit Access 2016
    Join Date
    May 2013
    Posts
    163

    Function


    This may be above my pay grade but here goes.

    I'd like to make Function (arg1 as currency, arg2 as currency)

    In the code, I'd like to go through a table or query (Which ever is easier, I'll set it up that way) and get a sum of one of the fields. I only
    want to include records that match arg1 and arg2, which are two other fields in the record.

    More plainly, since this may not even be the best way, I have a procedure that is going to create a record in a table. A couple of the fields in the table need to be populated with currency data. I have a table (or query if need be) that has the info but it has to match certain criteria, and that criteria is located in fields other than the field I'm summing.

    Another way of doing it that I think may be a thing, is to set up a query that asks for parameters that can be passed from code and then use the resulting sum in the code, but I have no idea how to do that either. I know how to set up the query but not the code to automate it.

    Thank you

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I'm not sure I'm understanding, but you could open a recordset or use DSum:

    DSum("FieldName", "TableName", "Field1 = " & arg1 & " AND Field2 = " & arg2)
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    lefty2cox is offline Competent Performer
    Windows 7 64bit Access 2016
    Join Date
    May 2013
    Posts
    163
    Beautiful. Works like a charm. Thank you very much.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Happy to help!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 15
    Last Post: 10-17-2018, 09:26 PM
  2. Replies: 15
    Last Post: 05-31-2017, 02:10 PM
  3. Replies: 2
    Last Post: 02-26-2017, 11:31 AM
  4. Replies: 3
    Last Post: 03-04-2016, 10:36 AM
  5. Replies: 8
    Last Post: 11-04-2014, 10:44 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums