Test for BOF in a recordset

Here is the SQL statement I currently have:

SELECT tblEqpt.EqptID, NZ([Amount],"0") AS CalcAmount, NZ([COAmount],"0") AS CalcCOAmount, NZ([InvoiceAmount],"0") AS CalcInvoiceAmount, (NZ([Amount])+NZ([COAmount])-NZ([InvoiceAmount])) AS [Amount Remaining]
FROM tblReq INNER JOIN ((tblEqpt INNER JOIN tblChangeOrder ON tblEqpt.EqptID = tblChangeOrder.EqptID) INNER JOIN tblInvoice ON tblEqpt.EqptID = tblInvoice.EqptID) ON tblReq.ReqID = tblEqpt.ReqID
WHERE (((tblEqpt.EqptID)=[Forms]![frmRequisition]![txtLink]));

2 possibilities will exist
1. tblChangeOrder may not have any rows
2. tblInvoice may not have any rows

If this is the case, I need the calculation to be performed just as if [COAmount] were 0 and [InvoiceAmount] were 0.

I thank you in advance for your assistance.
Who is Participating?
As described in the other question, you'll need the so-called outer-join.

Double-click the connection lines between the three tables and change the option into 2 or 3 making tblEqpt leading.

Rey Obrero (Capricorn1)Commented:
Save your query as Query1

Dim rst As DAO.Recordset
Dim db As DAO.Database
Dim rs As Recordset
    Set db = CurrentDB()
    Set rst = db.OpenRecordset("Query1", dbOpenDynaset)
  If rst.BOF = True Then  'No records

 'your codes for calculation

    End If
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.