B
Bob
I have a small database in Access 2002 which records commission payments
made to a loan broker.
The following query (qryMissingCommission)(made with kind advice from
Duane Hookum) searches for any months that a commission payment was not
received for a particular Loan number. In this case Loan number 1.
SELECT tblDate.MonthYear
FROM tblDate
WHERE MonthYear < Now()
AND Format ([MonthYear],"mmmm,yyyy")
Not In (
SELECT Format ([PaymentDate],"mmmm,yyyy")
FROM tblCommission
WHERE LoanNo =1);
I wish to be able to run the query many times changing the LoanNo value
each time without user intervention.
I am assuming some form of do-while loop.
I guess the data returned from a query iteration would have to be
appended to the data from the previous iteration and stored somewhere (
maybe an array variable) so it could be used in a report.
I have begun with the following code suggested in an earlier post by
Allen Browne.
Dim myvalue As String
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim qdf As DAO.QueryDef
Set dbs = CurrentDb
Set qdf = dbs.QueryDefs("qryMissingCommission")
Set rst = qdf.OpenRecordset
rst.MoveFirst
Do While rst.EOF = False
myvalue = rst.Fields("LoanNo").Value
MsgBox myvalue
rst.MoveNext
Loop
rst.Close
qdf.Close
Set rst = Nothing
Set qdf = Nothing
dbs.Close
Set dbs = Nothing
but I get an "Item not found" error on this line
myvalue = rst.Fields("LoanNo").Value
Any thoughts on how to solve this.
Thankyou
Bob Wickham
made to a loan broker.
The following query (qryMissingCommission)(made with kind advice from
Duane Hookum) searches for any months that a commission payment was not
received for a particular Loan number. In this case Loan number 1.
SELECT tblDate.MonthYear
FROM tblDate
WHERE MonthYear < Now()
AND Format ([MonthYear],"mmmm,yyyy")
Not In (
SELECT Format ([PaymentDate],"mmmm,yyyy")
FROM tblCommission
WHERE LoanNo =1);
I wish to be able to run the query many times changing the LoanNo value
each time without user intervention.
I am assuming some form of do-while loop.
I guess the data returned from a query iteration would have to be
appended to the data from the previous iteration and stored somewhere (
maybe an array variable) so it could be used in a report.
I have begun with the following code suggested in an earlier post by
Allen Browne.
Dim myvalue As String
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim qdf As DAO.QueryDef
Set dbs = CurrentDb
Set qdf = dbs.QueryDefs("qryMissingCommission")
Set rst = qdf.OpenRecordset
rst.MoveFirst
Do While rst.EOF = False
myvalue = rst.Fields("LoanNo").Value
MsgBox myvalue
rst.MoveNext
Loop
rst.Close
qdf.Close
Set rst = Nothing
Set qdf = Nothing
dbs.Close
Set dbs = Nothing
but I get an "Item not found" error on this line
myvalue = rst.Fields("LoanNo").Value
Any thoughts on how to solve this.
Thankyou
Bob Wickham