Note that there are some explanatory texts on larger screens.

plurals
  1. POlooping in 3d array access vba not returning all results
    primarykey
    data
    text
    <p>I have a project with 4 scheduled payments associated with 4 "contract" dates, stored in tblPaySch However, sometimes we receive the payments (stored in tblTrans), in different amounts on different dates (the "Actual") date</p> <p>I am attempting an array that defines the 4 dates (identified by ID 1 - 4) and the expected amount, then compares it against the tblTrans to to see if the expected payment has been exceeded, and if so, mark that transaction date as the "Actual" date.</p> <p>There's either something wrong with my array or something wrong with my loop, as I can get the results for ID1, (i.e, the associate expected pay and the transaction date that met it), but can't get the other 3 IDs.</p> <p>I'm calling it in a query with GetDate(prjID) to pass the prjId to the function.</p> <p>Here is my code:</p> <pre><code>'This function is a multidimensional array that can hold multiple values Public Function GetDate(intID As Long) As Variant Dim intTot As Long Dim i As Integer Dim i2 As Integer 'Define recordset to get expected payment data Dim rsPrj As DAO.Recordset Set rsPrj = CurrentDb.OpenRecordset("SELECT * FROM tblPaySch WHERE PrjID =" &amp; intID, dbOpenSnapshot) 'Define recordset to get transaction data Dim rs As DAO.Recordset Set rs = CurrentDb.OpenRecordset("Select * from tblTrans where PrjID=" &amp; intID, dbOpenSnapshot) 'Store milestone payments in RA Dim RA(0 To 4, 0 To 4, 0 To 4) As Variant RA(0, 0, 0) = rsPrj!MSCdbID 'payment Id, 4 of which are associated with each PrjID RA(0, 1, 0) = rsPrj!PayIncGST 'expected payment amount, of 4 different totals RA(0, 0, 1) = rs!RefDate 'Actual date from tblTrans intTot = 0 Do While rs.EOF intTot = intTot + rs!Amt 'refers to the amount of the transaction '-----Check for milestone exceeded For i = 0 To 4 For i2 = 0 To 4 If IsNull(RA(i, i2, 1) And RA(i, i2, 0) &lt;= intTot) Then RA(i, i2, 1) = rs!RefDate End If Next i2 Next i Loop GetDate = RA(0, 0, 1) Debug.Print RA(1, 0, 0) Debug.Print RA(0, 1, 0) Debug.Print RA(0, 0, 1) End Function </code></pre> <p>Thank you in advance, and please excuse any obvious noobie mistakes, this is my first ever array function.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload