Select Records based another table...

This may be very elementary, but i can't wrap my brain around it.  I have
tried to dummy it down as much as i can for myself, with plans of adapting it
into something working.  I have three tables that look like the following:

Tbl 1:
ProdID     A     B     C
    1        $1    $2    $3
    2        $4    $5    $6
    3        $7    $8    $9

Tbl 2:
RmNum      ProdID
     1               3
     1               2
     2               1
     2               2

Tbl 3:
RmNum     Style
     1             A
     2             C

Relationships are:
[tbl1 ProdID] ------ [tbl2 ProdID]
[tbl2 RmNum] ------ [tbl3 RmNum]

What i want to do is create a query, and a report off of that query, that
gives me the price from Tbl1 "column" based on the Style selection in Tbl3.
So since there is product 3 and 2 in RmNum 1 (from Tbl 2) and style A for
RmNum 1 in Tbl 3, the total would be $11.  The same situation for RmNum 2
total would be $9.  I hope this makes sense and someone can at least point me
in the right direction.  Thanks!

-- 
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-queries/200801/1

0
brownti
1/3/2008 8:08:16 PM
access.queries 6343 articles. 1 followers. Follow

2 Replies
999 Views

Similar Articles

[PageSpeed] 13

Your tbl 1 isn't set up properly. It probably should look like so:
ProdID  Style   Cost
1      A      $1.00
1      C      $3.00
1      B      $2.00
2      A      $4.00
2      B      $5.00
2      C      $6.00
3      A      $7.00
3      B      $8.00
3      C      $9.00

Then the following query will work:

SELECT [Tbl 3].Style,
 Sum([Tbl 1].Cost) AS SumOfCost
FROM ([Tbl 2] INNER JOIN [Tbl 1] ON [Tbl 2].ProdID = [Tbl 1].ProdID)
 INNER JOIN [Tbl 3] ON ([Tbl 3].Style = [Tbl 1].Style)
 AND ([Tbl 2].RmNum = [Tbl 3].RmNum)
GROUP BY [Tbl 3].Style;

I must say that the joins are somewhat strange so you may need more data 
normalization to set up your tables correctly.
-- 
Jerry Whittle, Microsoft Access MVP 
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.

"brownti via AccessMonster.com" wrote:

> This may be very elementary, but i can't wrap my brain around it.  I have
> tried to dummy it down as much as i can for myself, with plans of adapting it
> into something working.  I have three tables that look like the following:
> 
> Tbl 1:
> ProdID     A     B     C
>     1        $1    $2    $3
>     2        $4    $5    $6
>     3        $7    $8    $9
> 
> Tbl 2:
> RmNum      ProdID
>      1               3
>      1               2
>      2               1
>      2               2
> 
> Tbl 3:
> RmNum     Style
>      1             A
>      2             C
> 
> Relationships are:
> [tbl1 ProdID] ------ [tbl2 ProdID]
> [tbl2 RmNum] ------ [tbl3 RmNum]
> 
> What i want to do is create a query, and a report off of that query, that
> gives me the price from Tbl1 "column" based on the Style selection in Tbl3.
> So since there is product 3 and 2 in RmNum 1 (from Tbl 2) and style A for
> RmNum 1 in Tbl 3, the total would be $11.  The same situation for RmNum 2
> total would be $9.  I hope this makes sense and someone can at least point me
> in the right direction.  Thanks!
> 
> -- 
> Message posted via AccessMonster.com
> http://www.accessmonster.com/Uwe/Forums.aspx/access-queries/200801/1
0
Utf
1/3/2008 9:11:00 PM
I'm not sure what the last part of your post means...

Jerry Whittle wrote:
>Your tbl 1 isn't set up properly. It probably should look like so:
>ProdID  Style   Cost
>1      A      $1.00
>1      C      $3.00
>1      B      $2.00
>2      A      $4.00
>2      B      $5.00
>2      C      $6.00
>3      A      $7.00
>3      B      $8.00
>3      C      $9.00
>
>Then the following query will work:
>
>SELECT [Tbl 3].Style,
> Sum([Tbl 1].Cost) AS SumOfCost
>FROM ([Tbl 2] INNER JOIN [Tbl 1] ON [Tbl 2].ProdID = [Tbl 1].ProdID)
> INNER JOIN [Tbl 3] ON ([Tbl 3].Style = [Tbl 1].Style)
> AND ([Tbl 2].RmNum = [Tbl 3].RmNum)
>GROUP BY [Tbl 3].Style;
>
>I must say that the joins are somewhat strange so you may need more data 
>normalization to set up your tables correctly.
>> This may be very elementary, but i can't wrap my brain around it.  I have
>> tried to dummy it down as much as i can for myself, with plans of adapting it
>[quoted text clipped - 28 lines]
>> total would be $9.  I hope this makes sense and someone can at least point me
>> in the right direction.  Thanks!

-- 
Message posted via http://www.accessmonster.com

0
brownti
1/4/2008 1:14:00 PM
Reply:

Similar Artilces:

Combo box list selection based on earlier selection by user
HI, I have a form that has a combo box 1 (Product) that reads a the Product table and has a unique id attached to each product (RO#). There is a second combo box 2 that is RO#. Now what I would like to do is when a user selects a Product in combo box 1, the system should lookup the Product selected from combo box 1 and upload the corresponding RO# in the combo box 2 list. Now I am using both combo boxes as Unbound and in the combo box 2 I have the two columns Product and RO# - in the Criteria row of RO# I have the following: Like IIf([Forms]![xa_f_lookup]![RO#]=" ",[Forms]![x...

Run report on multi selected records.
I try to make a report for a custom entity that works like the Account Summary: let's say that it's Customer's Inquiry Summary for entity Customer's Inquiry I made the report so that I'm able to run the report on Customer's Inquiry Form. But when I select multi records in the list of Customer's Inquiry and run report, only one record is show in one page of the the report. I would like to have the selected records appear in the report with each record on each page. How can I do this? ...

Query-based list w/1 Exception
I've created a query based distribtuion list which works fine yet out of the 1000 or so mailboxes it gives me I'd like to exclude 10. Is there a way? (Basically I have checked only "Users with Exchange mailbox") Make those 10 recipients members of a distribution group, and add the following to the query: (&(your current query)(!memberOf=distinguished Name of the distribution group)) Alternatively, if there's a common value of a particular attribute like location/city/department, et al, use that to exclude them. -- Bharat Suneja MVP - Exchange www.zenprise.com ...

Pivot Table Data
This is a multipart message in MIME format. --=_alternative 006B899F86256E2F_= Content-Type: text/plain; charset="us-ascii" I have a file that contains pivot tables along with some buttons and macros to change the way the pivot table looks depending on what type of information that you would like to view. The pivot table is based on data on a separate worksheet but is within the same workbook (separate tabs). If I change my data source (i.e. I change the names of individuals to new names) and refresh my pivot table, the information changes like I want it to. However, if I de...

Count uniq records and assign to a control
SID is the field of underline query of a form (have many duplicates). I want to count number of uniq SID and assign the result to TotalStudent control on the form. Please help. Thanks - Song In article <e90AFyUbHHA.1388@TK2MSFTNGP05.phx.gbl>, csitnnn@hotmail.com says... > SID is the field of underline query of a form (have many duplicates). I want > to count number of uniq SID and assign the result to TotalStudent control on > the form. Please help. Thanks > > - Song > > > Maybe with a saved query such as Query1: SELECT DISTINCT SID FROM UnderlyingQ...

Can't select objects in Excel 2007
I'm trying to create a form in Excel 2007, and although I can manipulate, copy & paste controls (check boxes, etc) I can't select multiple objects to align them, etc. I've checked on-line help (and have followed the instructions), and other websites, but no one seems to have indicated a problem. It is extremely cumbersome and I need a solution. Any ideas? Thanks in advance, Jim Berglund I know this is about a year too late, but it may help others who have stumbled across this page looking for similar help. On the Home tab, in the Editing group, click Find & Select....

Set Records Per Page Default
Hi, I'm new to CRM (version 4.0) and have been asked by the boss if it is possible to default the "records per page" option to 250 for all new users rather than the usual 50. I've been through three books now (Microsoft Dynamics CRM 4 for Dummies, Step by Step Microsoft Dynamics CRM 4.0 and Working with Microsoft Dynamics CRM 4.0) and while they all mention that 50 is the default, none of them mentions a way of changing that. Does anyone here know of a way of changing the default? Thanks, Tony. As far as I know there is no default setting for all users. -- htt...

Lot Selection not Showing when I select PO on Receiving Entry
Usually, the Lot selection screen would pop up when I select a PO at the Line Detail of the Receivings Entry, now it does not! And GP will let items post without a lot number! It seems as if a setting has changed. Any ideas anyone? Any help is appreciated. Thanks, R Are you sure the item is marked to track lots? This wiould be set item by item on the Item Maintenance Options window. -- Richard L. Whaley Author / Consultant / MVP 2006-2008 Documentation for Software Users Get our Free Tips and Tricks Newsletter and check out our books at http://www.AccoladePublications.com &q...

Select contact then hangs
Hi, please help. I have a user that when she selects a contact using To: in a new email, after selecting 2, it closes outlook??. Spec is W2kSP4\office2k with all windows updates and office updates installed. Profile has been deleted and re-created, plus i have set up personal folders and moved contacts into there, and set that folder as a default, but makes no difference. Please help. ...

Open & update another file (through macro) while running macro
I am using MS Excel 2003 and I need help to solve my problem. One excel file (suppose A.xls) in which I’ll update my graph and the data is available in another file (suppose B.xls). What I am doing (through macro) is that I have created one button (in A.xls) and when I pressed it; its open the file B.xls (the data file) and at their I select month from drop down from which its update the pivot table based on the selection month and then same I was doing with another data excel file (suppose C.xls). Query : Is there any solution that when I pressed button from file A.xls its ...

Selecting rows from various sheets
Hi all, I have several sheets with a few columns in each. One colum in each sheet has a unique value. Most of these unique values are th same in each sheet but not all. Is there any way that I can set up new sheet that will have the unique value in column 1 and th corresponding column values frommeach sheet beside it. For example Sheet 1 aa 1 1 1 bb 2 2 2 cc 3 3 3 Sheet 2 aa 4 4 cc 5 5 Result aa 1 1 1 4 4 bb 2 2 2 cc 3 3 3 5 5 Thanks alot, Sha -- sha ----------------------------------------------------------------------- shav's Profile: http...

Have Stores Create Records in HQ
Is it possible to have the stores databasse create records in the HQ dbase and not the other way around? For eg. Sometimes clients forget when they get new products to create it in HQ then send out to stores. Merci We have a utility to allow you to create an item simultaneousely at store and in HQ. Contact m efor more detail. Afshin Alikhani - [afshin@retailrealm.co.uk] CEO - Retail Realm "SIDSolutions" wrote: > Is it possible to have the stores databasse create records in the HQ dbase > and not the other way around? For eg. Sometimes clients forget when they get &g...

select text in Calendar
I'm working on a calendar in Publisher. I'm adding text into a cell by spacing down 1 point, then typing in 8 points. Doing fine until April. At that time, I can only select cells (whole days). It will not let me select the text. Help is no help. Any hints out there. Did I accidentally select something to do this? Bonnie Have you added a picture to the cell or a shape? If you have send it to the back, make the cell no fill and try again. -- Mary Sauer MSFT MVP http://office.microsoft.com/ http://msauer.mvps.org/ news://msnews.microsoft.com "GoBonnieGo" <GoB...

Inserting ID Number from Another Table
Hello, I have two tables. One stores "employee information" and another stores "time sheet information" for all the employees. The "Employees" table has a unique identifier for each employee (EmployeeID). The "Time Sheet" table also has a unique identifier for each time sheet entry (TimeSheetID). When the data entry person inputs time sheet information onto the "TimeSheet" table, she selects the employee from a combo box which combines the first and last name of the employee from the employee table. What I want to do is automatically inse...

Another Formulae Baffle
I am trying to create a query? that will return a value, depending on the input value tothat cell. Tried using "if" but can only nest so many. I want a,b,d,e,h,l,s,t,x,z (if inputted for a days work) to return (hours worked) 8,4,9,6,1,8,8,8,0.25,0.50... tks if u can help... -- ShaneBrowning Hi Shane, Use VLOOKUP() Here's how: http://www.contextures.com/xlFunctions02.html -- Kind regards, Niek Otten Microsoft MVP - Excel "Shane" <shane@newcastle.com.au> wrote in message news:69947B47-73B9-4496-BD84-C87C70EB0A43@microsoft.com... |I am trying to create ...

programatically insert record
I have a many to many relationship between security clearances and billets. a clearance can be associated with more than one billet and a single billet can be associated with many clearances. That; however, may not have anything to do with my problem. I've built a form that has a listbox that displays the assocaited billets for an employee's clearance. Next to it I put a drop down list box that looks up the list of billets and stores it's value for later use. I've then added an "add" button underneath the drop down list box. What i'd like to do is cho...

Copying a formula to another page
Hello, I am a new user to Excel. I am working with a spreadsheet that and I want to pull the formula for one spreadsheet to another. What are the procedures for copying the formula. Thanks, Lisa >-----Original Message----- >Hello, > >I am a new user to Excel. I am working with a spreadsheet >that and I want to pull the formula for one spreadsheet to >another. What are the procedures for copying the formula. > >Thanks, >Lisa >. > Lisa, Try entering the tab name of the sheet from which you want to copy the formula from in a cell in the sheet you want ...

How to switch Office Enterprise 2007 from one computer to another
I recently bought a new computer. I have Office Enterprise 2007 loaded on my old computer. When I tried loading the product onto the new computer it said I had maxed out the number of computers I am allowed. Question: How do I get the "authorized" software off my old computer (which is being trashed once I do this) and get it on the new computer? You get all the documentation that came with your HUP of Office 2007 Enterprise along with the info that was given to you from the Company where you purchased it and use the phone as per below Here you will find the Phon...

macro to filter data based on selected data
Hi, I am looking for a macro that requests input of a reference code and then a date and then filters the data in my spreadsheet based on this criteria. I am using excel 2007. Any help with this will be greatly appreciated. You can probably record a macro while doing it manually and then clean it up and add input boxes to ask the question or input your variable in a cell and use that. If all else fails, If desired, send your file to my address below. I will only look if: 1. You send a copy of this message on an inserted sheet 2. You give me the newsgroup and the ...

Link select with a blast
I have Win 7 Home Premium, x64. Quite often, when I select a link, a mouse pointer changes to a palm with a blast. I understand, the palm is the standard mouse pointer for link select, but what is the blast? What it indicates? -- Ilya Zeldes Fort Myers, Florida Hi Ilya, I suspect that this is being caused by a tracking program. Run something like Ad-Aware and see if it indicates a tracking company. If so, you can delete it, however, it might prevent you from accessing that particular website. Dave "Ilya Zeldes" wrote in message news:7A6FF9B1-5512-44...

Deleting duplicate records 01-21-10
I populated a table using an Append query. I created a duplicate records query using the Wizard. There are 20000 records. Now I need to delete the duplicates out of this query. How do I do that? this may be a duplicate post, im not seeing my first one. anyways, instead of deleting those duplicate records, lets just grab all the records that are not duplicates. (an unmatched query). do a LEFT JOIN from your main table to your duplicate table/query on primary keys. Choose your primary key from the DUPLICATE table, and set the criteria to Is Null. This will pull ALL Recor...

No customer record exists for this customer ID
This message came up during the posting process. Why did SOP allow the invoice to be created? A few questions: 1. Does the Customer ID actually exist? 2. Is there a possibility that the customer record was physically removed, say with a T-SQL DELETE statement *after* the SOP transaction record was created? 3. Is there a possibility that the customer's Customer ID was accidentally updated with a T-SQL UPDATE statement *after* the SOP transaction record was created? If the customer record is missing, I would restore the last known good backup into a test environment, then transfer ...

Macro to switch to another sheet, grab ref to any cell, paste ref in current sheet??
I am looking for a way (either macro or VBA) to perform one simple task: while in *any cell* of your choice in the current worksheet, switch to another specific sheet, choose *any* cell, grab a reference to that cell (not its value), switch back to the first worksheet and slap in the reference of the cell in the other sheet. This would be the automated equivalent of doing the following manually: 1) Select *any cell* (say *F11*) in the current sheet (Call it "*Destination*"). 2) Press "=" (no "ENTER") 3) Click the tab for the other sheet (call it "*Source*&...

Counting number of records based on criteria
Hello, (Try again to get the question in the google-groups. Perhaps not pushed on the send button). For counting records as expression in a report in ms.access I'm using =count(*) which shows all records. Now I also want to know how many of them has registered a specific data in a specific field. I'm trying to use =count([Field1]="999") to count how many of the selection reported has registered data 999. This option isn't work. Can somebody give me the correct solution. thanks, Johan The 999 needs to go in the criteria for the query driving the...

Select Case in a Change Event
Hi, I am trying to use a worksheet Change Event to trap changes to specific columns. depending on which column is chnaged by the user, the value in another ciolumn will be altered; so, changes in either column O or P will update column Q, changes in either column T or U will update column V and changes in column Z or AA will update column AB. What I can't figure out is the Select Case bit (where I've got the shouted question below). Here's what I've put together, any comments would be much appreciated. Private Sub Worksheet_Change(ByVal Target As Range) ...