Results 1 to 4 of 4
  1. #1
    antioch is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Jul 2017
    Posts
    8

    Post Multiplying records with certain dates

    I've looked through many threads, but didn't see an answer to this problem that I'm trying to solve. I have a query table which has the following 3 fields:

    date return compound
    3/31/01 A E


    6/30/01 B F
    9/30/01 C G
    12/31/01 D H

    I'm trying to find the code to solve for the compound field...so H = (1+D)*(1+C)*(1+B) and G=(1+C)*(1+B)*(1+A), etc. Could anyone help me with this? I really appreciate it!!

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    You need to pull values from multiple records? This won't be easy. How do you know which records go together?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    This works I think

    Code:
    Function concmultiple(val As Integer) As Double
    
    Dim dbs As DAO.Database
    Dim rsTable As DAO.Recordset
    Dim rsQuery As DAO.Recordset
    Dim multcount As Integer
    Dim totvalue As Double
    Set dbs = CurrentDb
    totvalue = 1
    CurrentDb.QueryDefs("qrymyquery").SQL = "SELECT TOP " & val & " tbl1.percentage, tbl1.ID FROM tbl1;"
    'Open a dynaset-type Recordset using a saved query
    Set rsQuery = dbs.OpenRecordset("qryMyQuery", dbOpenDynaset)
    rsQuery.MoveLast
    multcount = rsQuery.Fields("ID")
    
    'MsgBox multcount
    rsQuery.MoveFirst
    With rsQuery
          Do While Not rsQuery.EOF
          totvalue = totvalue * (.Fields("percentage") + 1)
    
    .MoveNext
    Loop
    End With
    rsQuery.Close
    concmultiple = totvalue
    End Function

    The code could go in any module
    And is called from queryrun

    you may still have to get round that the ID numbers are necessary

    hope it helps anyway




    Click image for larger version. 

Name:	Capture2.PNG 
Views:	14 
Size:	8.4 KB 
ID:	29634Click image for larger version. 

Name:	pic1.PNG 
Views:	14 
Size:	9.3 KB 
ID:	29635

  4. #4
    antioch is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Jul 2017
    Posts
    8
    Thanks...I'll try that in the office tomorrow.

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

Similar Threads

  1. Select Records based on dates or no dates or both
    By usatraveler in forum Queries
    Replies: 3
    Last Post: 08-12-2016, 07:52 AM
  2. Multiplying two values from the same column
    By jplank in forum Queries
    Replies: 1
    Last Post: 11-26-2013, 12:27 PM
  3. Multiplying columns with a WHERE condition
    By j9070749 in forum Access
    Replies: 14
    Last Post: 11-02-2013, 04:55 PM
  4. Multiplying two tables question
    By mmanzo1001 in forum Access
    Replies: 10
    Last Post: 10-14-2011, 10:14 AM
  5. Multiplying
    By chazcoral2 in forum Forms
    Replies: 16
    Last Post: 09-10-2010, 01: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