Advertisement

05.09.2008 at 01:54PM PDT, ID: 23390812
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

Cannot have aggregate function in WHERE clause
Tags: microsoft, access 2003, 2003
I get a "Cannot have aggregate function in WHERE clause: ((([Quantity]-Sum(nz([MeasureQuantity])))<>0))"

Any idea why this is happening?

Thanks, JOe K.

Here is my SQL:
1:
2:
3:
SELECT [Quantity]-Sum(nz([MeasureQuantity])) AS TQ, tblPO_Details.PO_DetailsID
FROM tblPO_Details LEFT JOIN tblOrdersItems ON tblPO_Details.PO_DetailsID = tblOrdersItems.PO_DetailsID
WHERE ((([Quantity]-Sum(nz([MeasureQuantity])))<>0));
Start your free trial to view this solution
Question Stats
Zone: Microsoft
Question Asked By: ClaudeWalker
Solution Provided By: nico5038
Participating Experts: 6
Solution Grade: A
Views: 18
Translate:
Loading Advertisement...
05.09.2008 at 01:57PM PDT, ID: 21536357

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.09.2008 at 01:57PM PDT, ID: 21536360

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.09.2008 at 01:57PM PDT, ID: 21536362

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.09.2008 at 02:14PM PDT, ID: 21536449

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.09.2008 at 02:57PM PDT, ID: 21536625

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.09.2008 at 03:17PM PDT, ID: 21536718

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.09.2008 at 03:24PM PDT, ID: 21536756

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.09.2008 at 03:31PM PDT, ID: 21536780

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.09.2008 at 04:18PM PDT, ID: 21536981

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.09.2008 at 04:25PM PDT, ID: 21537036

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.09.2008 at 04:35PM PDT, ID: 21537108

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.09.2008 at 04:36PM PDT, ID: 21537111

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.09.2008 at 05:58PM PDT, ID: 21537426

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.09.2008 at 07:04PM PDT, ID: 21537556

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.09.2008 at 07:12PM PDT, ID: 21537577

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.10.2008 at 03:37AM PDT, ID: 21538435

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.10.2008 at 10:40AM PDT, ID: 21539838

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.10.2008 at 11:39AM PDT, ID: 21540104

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.10.2008 at 11:48AM PDT, ID: 21540130

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.10.2008 at 12:00PM PDT, ID: 21540164

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.10.2008 at 12:10PM PDT, ID: 21540195

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.10.2008 at 12:14PM PDT, ID: 21540208

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.10.2008 at 12:22PM PDT, ID: 21540233

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.10.2008 at 12:57PM PDT, ID: 21540321

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.10.2008 at 02:00PM PDT, ID: 21540466

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.10.2008 at 02:36PM PDT, ID: 21540560

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
Microsoft
  • Internet Protocols
  • Applications
  • Development
  • OS
  • Hardware
  • Windows Security
Apple
  • Operating Systems
  • Hardware
  • Programming
  • Networking
  • Software
Internet
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Spy / Ad Blockers
  • Web Browsers
  • New Net Users
  • Web Development
  • Chat / IM
  • Anti Spam
  • Web Servers
  • Anti-Virus
  • Email Clients
Gamers
  • Tips
  • Online / MMORPG
  • Puzzle
  • Emulators
  • Action / Adventure
  • Role Playing
  • Consoles
  • Game Programming
  • Strategy
  • Sports
  • Misc
  • Computer Games
Digital Living
  • Hardware
  • New Net Users
  • New Users
  • Software
  • Digital Music
  • Gaming World
  • Home Security
  • Apple
  • Networking Hardware
Virus & Spyware
  • Vulnerabilities
  • IDS
  • Encryption
  • Anti-Virus
  • Operating Systems Security
  • Software Firewalls
  • WebApplications
  • Cell Phones
  • Operating Systems
  • Internet
  • Hardware Firewalls
Hardware
  • Handhelds / PDAs
  • Displays / Monitors
  • Components
  • Networking Hardware
  • Peripherals
  • Laptops/Notebooks
  • Storage
  • Servers
  • Desktops
  • New Users
  • Misc
  • Apple
Software
  • System Utilities
  • Industry Specific
  • Network Management
  • Photos / Graphics
  • Page Layout
  • VMWare
  • Misc
  • Web Development
  • OS
  • CYGWIN
  • Voice Recognition
  • Message Queue
  • Quality Assurance
  • Security
  • Firewalls
  • MultiMedia Applications
  • Development
  • Database
  • Office / Productivity
  • Business Management
  • OS/2 Apps
  • Server Software
  • Internet / Email
ITPro
  • OS
  • Storage
  • Encryption
  • Operating Systems Security
  • Apple Hardware
  • Laptops & Notebooks
  • Servers
  • Networking Hardware
  • Peripherals
  • Devices
  • Displays / Monitors
  • WebTrends / Stats
  • Search Engines
  • Firewalls
  • WebApplications
  • IDS
  • Vulnerabilities
  • Email Clients
  • File Sharing
  • Spy / Ad Blockers
  • Web Browsers
  • Web Servers
  • Networking
  • Anti-Virus
  • Chat / IM
  • Anti Spam
Developer
  • Web Servers
  • Web Browsers
  • Game Programming
  • Dev Tools
  • Industry Specific
  • Office / Productivity
  • Database
  • CYGWIN
  • Web Development
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Programming
  • Content Management
  • Application Servers
  • Protocols
Storage
  • Removable Backup Media
  • Storage Technology
  • Servers
  • Grid
  • Remote Access
  • Backup / Restore
  • Misc
  • Hard Drives
OS
  • Miscellaneous
  • Security
  • Development
  • Linux
  • VMWare
  • MainFrame OS
  • Unix
  • Apple
  • OS / 2
  • AS / 400
  • BeOS
  • Microsoft
  • VMS / OpenVMS
Database
  • Oracle
  • Miscellaneous
  • MySQL
  • Software
  • Sybase
  • Contact Management
  • PostgreSQL
  • Data Manipulation
  • Clarion
  • InterSystems Cache
  • Siebel
  • MUMPS
  • OLAP
  • SQLBase
  • SAS
  • GIS & GPS
  • 4GL
  • Berkeley DB
  • DB2
  • Informix
  • Interbase / Firebird
  • FoxPro
  • Reporting
  • LDAP
  • Filemaker Pro
  • MS SQL Server
  • dBase
  • MS Access
Security
  • Misc
  • Web Browsers
  • Software Firewalls
  • Operating Systems Security
  • File Sharing
  • Spy / Ad Blockers
  • Vulnerabilities
  • WebApplications
  • IDS
  • Anti-Virus
  • Encryption
  • Anti Spam
  • Email Clients
  • VPN
  • Chat / IM
Programming
  • Editors IDEs
  • Installation
  • Handhelds / PDAs
  • Multimedia Programming
  • System / Kernel
  • Algorithms
  • Game
  • Signal Processing
  • Project Management
  • Open Source
  • Database
  • Misc
  • Languages
  • Processor Platforms
  • Theory
Web Development
  • Scripting
  • Blogs
  • Web Servers
  • Software
  • Search Engines
  • Web Graphics
  • Images
  • Internet Marketing
  • Images and Photos
  • Components
  • Document Imaging
  • Web Languages/Standards
  • Illustration
  • WebApplications
  • Fonts
  • WebTrends / Stats
  • Authoring
  • Digital Camera Software
  • Miscellaneous
Networking
  • Protocols
  • Apple Networking
  • Network Management
  • Message Queue
  • Application Servers
  • Content Management
  • File Servers
  • Email Servers
  • Misc
  • Java Editors & IDEs
  • Wireless
  • Networking Hardware
  • Backup / Restore
  • System Utilities
  • ISPs & Hosting
  • Web Servers
  • Storage Technology
  • Removable Backup Media
  • Servers
  • Broadband
  • Grid
  • OS / 2
  • Novell Netware
  • Unix Networking
  • Windows Networking
  • Security
  • Telecommunications
  • Operating Systems
  • Linux Networking
Other
  • Community Advisor
  • Lounge
  • Community Support
  • New Net Users
  • Philosophy / Religion
  • Math / Science
  • Miscellaneous
  • URLs
  • Expert Lounge
  • Politics
  • Puzzles / Riddles
Community Support
  • Suggestions
  • New to EE
  • New Topics
  • Community Advisor
  • CleanUp
  • Announcements
  • General
  • Feedback
  • Input
  • EE Bugs
 
05.09.2008 at 01:57PM PDT, ID: 21536357

Rank: Genius

can you clarify the data?
 
05.09.2008 at 01:57PM PDT, ID: 21536360

Rank: Genius

WHERE checks for conditions on **an individual row**.

You have to use HAVING to check summary/group values.  Such as:

WHERE ...
GROUP BY ...
HAVING SUM(...)  <> 0
 
05.09.2008 at 01:57PM PDT, ID: 21536362

Rank: Genius

>I get a "Cannot have aggregate function in WHERE clause:
Correct.  That would be the HAVING clause.

SELECT [Quantity]-Sum(nz([MeasureQuantity])) AS TQ, tblPO_Details.PO_DetailsID
FROM tblPO_Details
LEFT JOIN tblOrdersItems ON tblPO_Details.PO_DetailsID = tblOrdersItems.PO_DetailsID
HAVING [Quantity] - Sum(nz([MeasureQuantity])) <>0 ;
 
 
05.09.2008 at 02:14PM PDT, ID: 21536449
I tried using the HAVING and now I get a "You tried to execute a query that does not include the specified expression [quantity] - Sum(nz([MeasureQuantity])" as part of an aggregate function.

 
05.09.2008 at 02:57PM PDT, ID: 21536625

Rank: Genius

Now that I think of it, you may not be able to have an expression between an aggregate Sum(nz([MeasureQuantity])) and non-aggregate [Quantity] in the same SQL.

What tables to Quantity and MeasureQuantity belong in?  Perhaps a subquery can be used to pull this off.
 
05.09.2008 at 03:17PM PDT, ID: 21536718
tblOrdersItems.MeasureQuantity

tblPO_Details.Quantity

 
05.09.2008 at 03:24PM PDT, ID: 21536756

Rank: Genius

Give this a whirl (air code, and it's late in the day)...

SELECT po.Quantity - foo.TQ, po.PO_DetailsID
FROM tblPO_Details po
LEFT JOIN (
    SELECT tblPO_Details.YourIDField, Sum(nz([tblOrdersItems].[MeasureQuantity])) as TQ
    FROM tblPO_Details
    LEFT JOIN tblOrdersItems oi ON po.PO_DetailsID = oi.PO_DetailsID
    GROUP BY tblPO_Details.YourIDField)   foo ON po.YourIDField = foo.YourIDField
WHERE po.Quantity - foo.TQ <>0
 
 
05.09.2008 at 03:31PM PDT, ID: 21536780
What is po and foo?
 
05.09.2008 at 04:18PM PDT, ID: 21536981

Rank: Master

They are table aliases...
 
05.09.2008 at 04:25PM PDT, ID: 21537036
Thats what I figured but the "foo" threw me off.  What is foo?
 
05.09.2008 at 04:35PM PDT, ID: 21537108

Rank: Genius

air code:  C'mon Jim, if you are going to use aliases, you must be consistent in their use throughout the query.  BTW 'oi'??
 
05.09.2008 at 04:36PM PDT, ID: 21537111

Rank: Genius

You would need to add the Group By in jim's query to get the query working like:

SELECT ([Quantity]-Sum(nz([MeasureQuantity]))) AS TQ, tblPO_Details.PO_DetailsID
FROM tblPO_Details
LEFT JOIN tblOrdersItems ON tblPO_Details.PO_DetailsID = tblOrdersItems.PO_DetailsID
GROUP BY  tblPO_Details.PO_DetailsID
HAVING ([Quantity] - Sum(nz([MeasureQuantity]))) <>0 ;

Nic;o)
 
05.09.2008 at 05:58PM PDT, ID: 21537426

Rank: Genius

>C'mon Jim, if you are going to use aliases, you must be consistent in their use throughout the query.
fook
 
05.09.2008 at 07:04PM PDT, ID: 21537556
Thanks, for your response on a friday especially!
I'm actually gonna run back to the office and put this on a flash drive and your SQL out.  

<i just want to fill you in on the reasoning for the set up>

I have a continuous form where items can be assigned to installation measures.  Many items can goto many measures.

ex:
total 3 plywood and 1 box of screws

2 plywood goto the door install
1 plywood and 1 box of screws goes to the window install.  (hence many to many)

I have a continuous subform [sbfrmAssignItems] next to a listbox [lstMeasures] with 2 combo boxes ([cboItemID] which is locked, and [cboTempQuantity]) in sbfrmAssignItems .  

The user selects the measure in the list box (which stays highlighted) and then in the subform enters the cboTempQuantitiy of items that are associated with that measure.  They then Press F5 and the items are Appended to the many to many table [tblOrderItems] .  

In order to allow the user to put values for multiple items before appending them to the many to many table.  I had to create "temp table" so the comboboxes can have unique values in them.  Without that temp table all the comboboxes assume the same values.  

Measures and items are associated on the front end then F5 is pressed and then they are appended to the many to many table and are officially associated on the backend.  

******Everything works up to this point******

What I want to do is limit the user to only the items that are available.  If an item(s) are associated to a measure and there are no more to be associated I don't want them on the continuous subform.  

Normally this would be easy, In the query for the form I would count the quantity of an item from [tblOrderItems] subtract them from the quantity in the PO_Details table and if they equaled 0 then I would exclude them via the criteria.  

The problem is I can't get at the quantity in the [tblItemsAssoc] table because if I include it in my query I can no longer write values in the query (and the form).  I tried using DSum it works but goes incredibly slow and is bordering unstable.

I tried one other super complex method which changes the criteria of the query that the form is based on in VBA but I can't get the form to refresh without closing and opening the form.

Most importantly what decides when a query can and cannot be written in?  It is seemingly random to me why you can enter data in some querys and not in others.

How can I get that tblAssocItems included in my query to find out if there are items to yet be associated?

Or how can I repaint my subform after I change the underlying query of which it is based on (I would prefer not to go this route)?



 
05.09.2008 at 07:12PM PDT, ID: 21537577
I was also inconsistent in my above post.  when I say tblItemsAssoc I mean tblOrderItems.  I wish EE had an edit post option.

here are my 3 tables

tblPO_Details
____________
PO_DetailsID pk
Quantity
Price
ItemID fk
ExpendClassID fk

WXMeasureDetails (inconsistant naming convention I inherited a large un-normalized database, its to overused to change any time soon, but in the works)
_______________________
MeasureID pk
MeasureName (not normalized again)
[other none relevant fields]...

tblOrderItems (junction table)
_______________________
OrderItemsID pk
MeasureDetailsID fk
MeasureQuantity
PO_DetailsIID fk


This is a mouth full and may warrant another question to be fair points wise.  It would be unfair for me to change my question midway through.  I will try your query and post the results soon.  

Feel free to comment on what I have posted so far.

Thanks a million,

JOe K.
 
05.10.2008 at 03:37AM PDT, ID: 21538435

Rank: Genius

Hi Joe, looks to me you have the classic Bill Of Materials problem.
Check: http://en.wikipedia.org/wiki/Bill_of_materials to get the general description.
and
http://www.mvps.org/access/modules/mdl0027.htm
for a sample.

BTW, the query still hod a flaw, try:
SELECT Sum(nz([Quantity])-nz([MeasureQuantity])) AS TQ, tblPO_Details.PO_DetailsID
FROM tblPO_Details
LEFT JOIN tblOrdersItems ON tblPO_Details.PO_DetailsID = tblOrdersItems.PO_DetailsID
GROUP BY  tblPO_Details.PO_DetailsID
HAVING ([Quantity] - Sum(nz([MeasureQuantity]))) <>0 ;

As the Quantity needs to be "aggregated" too.

Nic;o)
 
05.10.2008 at 10:40AM PDT, ID: 21539838
Do you know what decides whether or not a query can be written too?  If I knew that it would help a ton for alot of future queries. I am going to work right now to get the project.
 
05.10.2008 at 11:39AM PDT, ID: 21540104

Rank: Genius

Hard time to understand your statement: Do you know what decides whether or not a query can be written too?
Basically every table row processing can be done using a query.
A simple SELECT query will allow you to filter the rows and a GroupBy will allow aggregations like Sum, Count, Min, Max, etc.
For modifications the UPDATE can be used and for removal the DELETE. Even tables can be created using queries.

What's the problem you see to decide to write a query ?

Nic;o)
 
05.10.2008 at 11:48AM PDT, ID: 21540130
Sorry about the delay I just ran to the office.

Let me re-phrase my question.  Some queries allow to me edit the data, others do not.  I am in a situation where I can't edit the data and therefore cannot edit the form.  It will not even allow me to enter anything into combo box.

Does that make sense?

I also tried to make a query based off of one table (a many to many table) and I couldn't add/edit records there either.

JOe K.
 
05.10.2008 at 12:00PM PDT, ID: 21540164

Rank: Genius

For forms I generally use a table (or a one table query) as the record source. When there's a linked table I use a linked sub form, thus Access will automatically filter the sub form and fill in the linking key of the main form in the subform new rows.
I call it "go by the flow" as it's the way Access supports by design.
When you use a query with a linked table that has a 1:N relation, then the query automatically turns into a "read-only" one as Access can't update the fields in the multiple occurrences of the "main" table.

The combo box refusal can have other reasons, but in general it's best to use a (hidden) unique first (bound) column and a description.

Getting the idea ?

Nic;o)
 
05.10.2008 at 12:10PM PDT, ID: 21540195
These 2 sub-queries work

qryAssignedTotals - this is the functioning aggregate sum query.  This is used to "filter" the PO details
_____________________________________________________________
SELECT Sum(nz([Quantity])-nz([MeasureQuantity])) AS TQ, tblPO_Details.PO_DetailsID
FROM tblPO_Details LEFT JOIN tblOrdersItems ON tblPO_Details.PO_DetailsID = tblOrdersItems.PO_DetailsID
GROUP BY tblPO_Details.PO_DetailsID
HAVING (((Sum(nz([Quantity])-nz([MeasureQuantity])))<>0));

qryItemsToBeAssigned - TempQuanity which is part of the sysOrderItemAssoc table is a temporary table for the purposes of holding the values in a temp location so they can be seen on the front end until they are sent to the back end
____________________________________________________________
SELECT tblPO_Details.PO_DetailsID, tblPO.FileNumber, tblPO_Details.Quantity, sysOrdersItemAssoc.TempQuantity
FROM (tblPO INNER JOIN (lstExpendClass INNER JOIN tblPO_Details ON lstExpendClass.ExpendClassID = tblPO_Details.ExpendClassID) ON tblPO.PO_ID = tblPO_Details.PO_ID) LEFT JOIN sysOrdersItemAssoc ON tblPO_Details.PO_DetailsID = sysOrdersItemAssoc.DetailsLink
WHERE (((lstExpendClass.ExpendClass) In ("Reg Cont","Reg Mat","H&S Cont","H&S Mat")))
ORDER BY tblPO_Details.PO_DetailsID;


This query opens but  the problem is I can't edit the records in the TempQuan field.
qryItemsToBeAssignedForm - is a combination of these two subqueries
________________________________________________________________
SELECT qryItemsToBeAssigned.PO_DetailsID, qryItemsToBeAssigned.FileNumber, qryItemsToBeAssigned.TempQuantity, qryItemsToBeAssigned.Quantity
FROM qryAssignedTotals INNER JOIN qryItemsToBeAssigned ON qryAssignedTotals.PO_DetailsID = qryItemsToBeAssigned.PO_DetailsID;


any idea why I can't write/edit the TempQuan field?

Thanks, JOe K.
 
05.10.2008 at 12:14PM PDT, ID: 21540208
>>Getting the idea ?

Kind of.

The combobox refusal is because the control source is the TempQuan field.

However, the 1:N relationship not allowing a query to be edited I don't understand.  I have a ton of queries where there are 1 to many relationships that I write too.  I don't see how someone could have a normalized database with out that.

for example: qryItemsToBeAssigned the 2nd query I have posted above I can input values into TempQuan

Thanks, JOe K.
 
05.10.2008 at 12:22PM PDT, ID: 21540233
>> When there's a linked table I use a linked sub form, thus Access will automatically filter the sub form and fill in the linking key of the main form in the subform new rows.

Lets say for example I have a PO_Details table :)

this table has 2 linked tables to it one called lstItem and lstClassExpend

SELECT DISTINCT tblPO_Details.PO_DetailsID, tblPO_Details.Quantity, tblPO_Details.UnitPrice, lstItem.Item, lstExpendClass.ExpendClass
FROM lstExpendClass INNER JOIN (lstItem INNER JOIN tblPO_Details ON lstItem.ItemID = tblPO_Details.ItemID) ON lstExpendClass.ExpendClassID = tblPO_Details.ExpendClassID;

The way I currently have this set up in my database is:

one form
cboItem txtQuantity txtUnit Price cboClassExpend

but is what your saying: this would be 3 forms???

parent (form) would contain PO_Details, ItemID, Quantity, UnitPrice, ClassExpendID

2 children (subforms)
one contains Item, and ItemID
one contains ClassExpend, ClassExpendID

Thanks, JOe K.

 
05.10.2008 at 12:57PM PDT, ID: 21540321

Rank: Genius

I see the initial Q has been answered, as you state that the qryAssignedTotals is working :-)

Normally when using an order we'll see an OrderHeader containing the CustomerID and a linked subform to show the address data of the customer.
Then we have a sub form to show the detail's, giving us as many rows as Products (items) that have been ordered. The "PriceToPay" here is a computed field being QuantityOrdered * UnitPrice.
The "Total Order Price" field is the sum of the "PriceToPay" and generally placed in an unbound field in the sub form's footer.

You use the lstClassExpend for getting the unit-price and that's something that can be deductible too when you have just one price per product/item it could be stored in the lstItem. Only with historical prices the story becomes more complex...

You might check the way the Northwind.mdb sample database is constructed to see my point.

Nic;o)
Accepted Solution
 
05.10.2008 at 02:00PM PDT, ID: 21540466