Solved

Checking detail file in header/detail relationship

Posted on 2014-04-07
2
233 Views
Last Modified: 2014-04-09
Hi,

I have a car repair business.

The header table is the "order" table with the customers name and address etc.
The detail is each part number used in the repair.

When the part number is unknown I use a dummy part code of "999".

However,I cannot flag an "order" as complete IF it has any details part number of "999".

SELECT Count(*) AS CountMissingNumbers, tblDetail.CustomerID
FROM tblDetail
GROUP BY tblDetail.[windowcode], tblDetail.CustomerID
HAVING (((tblDetail.[windowcode])="999") AND ((tblDetail.CustomerID)=[forms]![job1]![CustomerID]));

Open in new window


See snippet of code which checks for part number ="999".

Question: How do I "embed" this SQL into my VBA?

For purposes of the example, let's say I have a button on the order header which says "Complete Order".  This button calls my SQL check (and rejects the command if there are any 999's)
0
Comment
Question by:Patrick O'Dea
2 Comments
 
LVL 7

Accepted Solution

by:
COACHMAN99 earned 500 total points
ID: 39984369
use DCOUNT() function with order# as a param

  If DCount("ID", "Order Detail", "Order_ID=14 AND Part_Code=999") > 0 Then

  End If
0
 

Author Closing Comment

by:Patrick O'Dea
ID: 39990196
Excellent - works well
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Suggested Solutions

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

929 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now