Solved

Checking detail file in header/detail relationship

Posted on 2014-04-07
2
236 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
[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 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Undo Button 1 32
Limit number of characters returned to 999 9 31
MS Access How can I create a query for my report to filter the sub-form contents? 7 27
Null or "" 28 52
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
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.
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…

740 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