Solved

Checking detail file in header/detail relationship

Posted on 2014-04-07
2
232 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
Comment Utility
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
Comment Utility
Excellent - works well
0

Featured Post

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

771 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