Solved

Test for BOF in a recordset

Posted on 2004-03-20
2
236 Views
Last Modified: 2006-11-17
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.
0
Comment
Question by:CatDaddy2003
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 54

Accepted Solution

by:
nico5038 earned 500 total points
ID: 10641882
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.

Nic;o)
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 10641902
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
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Parameter Query 33 52
Select Query By design Can Not Convert To Update Query ! 9 38
Delete records based on common identifier from third table 2 31
MS Access Error Handling 6 30
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question