473,395 Members | 1,629 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Help with using the results of one query in another query

Hey,
I'm desperate for a clue in on how ms access can do this: I'd like take the maximum value from one field and then populate another field by dividing the values of the first field by the max.

An Example:

Field 1 Field 2
1 = 1/3
2 =1/3
3 =3/3

Rather than just using an update query to populate field 1 by dividing it by three, I'd like to divide it by the max, so changes can be made on the fly as the max value might change.

Any help would be greatly appreciated!
Mar 3 '07 #1
4 3344
ps I am using MS Access 2003 and I've got all my data in a single flat table with no set relationships

perhaps I need to establish relationships to get the single max value back into a query to update records in the master table?

Using the expression builder I have attempted to use an update query to do this:

[master]![Chin_Abun]/Max([master]![Chin_Abun])

where master is my table and "Chin_abun" is my field but it returns an error of that my "specific expression does not contain an aggregate function..."

What does that mean?

So is there a way to pass through the max value in another table and then reach out and grab it to divide that way?
Mar 3 '07 #2
Hey, I figured it out myself and here is an explanation of what wasn't working and what worked in case someone else is at the same holdup.

The goal: use a calculated value (a single max record) that is output in a select query in a mathematical expression with another table.

The problem: I needed to establish a "relationship" in access between the output max value with the original table it was derived from.

The solution: when designing an update query that would divide a field by its max value I brought in the master table and the query table and established a one-to-many link between the two tables. Before doing this I had to create a new field in the master and populate it with dummy data, ie coding all records as "1". Then in the original max output select query I used the "totals" function to define the max and then "grouped" by the dummy data field. This allowed, then, in the final query to establish the one-to-many link between the two tables by dragging the field records between the two table.

Once I did this I could then run the query successfully, in essence doing

New field to update= Value (in master table) / Max value (from query output)
Mar 3 '07 #3
ADezii
8,834 Expert 8TB
Hey,
I'm desperate for a clue in on how ms access can do this: I'd like take the maximum value from one field and then populate another field by dividing the values of the first field by the max.

An Example:

Field 1 Field 2
1 = 1/3
2 =1/3
3 =3/3

Rather than just using an update query to populate field 1 by dividing it by three, I'd like to divide it by the max, so changes can be made on the fly as the max value might change.
Any help would be greatly appreciated!
Assumptions:
__1 Table name is tblTest
__2 In the Query Grid, add Field 1 and a Calculated Field called CalcField (or any Name of your choosing) with the following expression:
Expand|Select|Wrap|Line Numbers
  1. CalcField: DFirst("[Field 1]","tblTest")/DMax("[Field 1]","tblTest")
OUTPUT:
Expand|Select|Wrap|Line Numbers
  1. Field 1    CalcField
  2. 1    0.333333333333333
  3. 2    0.333333333333333
  4. 3    0.333333333333333
Mar 4 '07 #4
NeoPa
32,556 Expert Mod 16PB
Hey, I figured it out myself and here is an explanation of what wasn't working and what worked in case someone else is at the same holdup.

The goal: use a calculated value (a single max record) that is output in a select query in a mathematical expression with another table.

The problem: I needed to establish a "relationship" in access between the output max value with the original table it was derived from.

The solution: when designing an update query that would divide a field by its max value I brought in the master table and the query table and established a one-to-many link between the two tables. Before doing this I had to create a new field in the master and populate it with dummy data, ie coding all records as "1". Then in the original max output select query I used the "totals" function to define the max and then "grouped" by the dummy data field. This allowed, then, in the final query to establish the one-to-many link between the two tables by dragging the field records between the two table.

Once I did this I could then run the query successfully, in essence doing

New field to update= Value (in master table) / Max value (from query output)
There seems a marked difference in style between your first two posts and the third ;)
Who cares where you got it from, you got your answer, and better than that, you were very helpful and posted a very well explained solution back in the thread so others could follow and get help too. Nice one.
If you need any help implementing this (I guess not but just in case) let us know. We would need some info about how the records are grouped that you want to process. Otherwise the info's all well stated.
BTW It is possible to do this in a single query if you use sub-queries (Subqueries in SQL). We can also help with the implementation of these with the required info.
Mar 4 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: netpurpose | last post by:
I need to extract data from this table to find the lowest prices of each product as of today. The product will be listed/grouped by the name only, discarding the product code - I use...
7
by: Phin | last post by:
I need your HELP! I've seen all the posts on using Crystal Reports within vs.net (vb.net) and changing a SQL query at runtime. When I tried to pass in a dataset into the crystal report at...
4
by: jimh | last post by:
I'm not a SQL expert. I want to be able to write a stored procedure that will return 'people who bought this product also bought this...'. I have a user table that links to a transaction table...
9
by: Dom Boyce | last post by:
Hi First up, I am using MS Access 2002. I have a database which records analyst rating changes for a list of companies on a daily basis. Unfortunately, the database has been set up (by my...
2
by: mmitchell_houston | last post by:
I'm working on a .NET project and I need a single query to return a result set from three related tables in Access 2003, and I'm having trouble getting the results I want. The details: ...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
47
by: Jo | last post by:
Hi there, I'm Jo and it's the first time I've posted here. I'm in process of creating a database at work and have come a little unstuck.....I'm a bit of a novice and wondered if anyone could...
5
by: deaconj999 | last post by:
Hi, I have nearly finished my database and I would like to add a query that uses a combo box to get the results, not the usual paramater style input. I suppose it would need a form and a query...
16
by: ARC | last post by:
Hello all, So I'm knee deep in this import utility program, and am coming up with all sorts of "gotcha's!". 1st off. On a "Find Duplicates Query", does anyone have a good solution for...
2
by: dmstn | last post by:
Hey! I've got a little problem. I have to make a web site for a university essay. I curently have to create a search engine. Users can enter a hotel name in a search bar and results have to appear in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.