Queries :: Child Records With Multiple Parents

Aug 3, 2014

I have modules and procedures. A module can consist of one or more procedures. A procedure can belong to one or more modules.

tblModules
--------
ModID
ModName

tblProcedures
----------
ProcID
ProcName

ModProcs
--------
ModProcID
ModID (FK)
ProcID (FK)

In a listbox I have a one or more modules selected and will construct the SQL in the AfterUpdate, presumably.

How to get a query to list only those procedures that belong to all the selected modules? To get into the result list a procedure must belong to all the modules that were selected. The code below gives me all the procedures that belong to at least one of the modules selected. I need ALL.

Code:

strIN = Left(strIN, Len(strIN) - 1) ' list of ModID's of selected in listbox
strSQL = SELECT tblModuleProcs.ProcID
FROM (tblModules INNER JOIN tblModuleProcs
ON tblModules.ModID = tblModuleProcs.ModID)
INNER JOIN tblProcedures ON tblModuleProcs.ProcID = tblProcedures.ProcID
WHERE (((tblModules.ModID) IN(" & strIN & "))) "
ORDER BY tblProcedures.ProcedureTag;

View Replies


ADVERTISEMENT

Tables :: Multiple Parents Table Linked To Child Table - Primary Keys

May 28, 2015

I have a table for a multiple parents linked to a child table. I need to figure out a way to only allow 1 parent to be coded as primary, 1 as secondary, and then the rest as other... I thought about making Primary/Secondary/Other a primary key. But then I can only have 1 other. I would have to make a finite number of parents that could be entered and I want an infinite number.... My end goal is to have a report that only has a primary and second parent on it, but the rest of the parents still exist in the table...

*Child_ID
Parent_First_Name
*Primary/Secondary/Other

View 8 Replies View Related

Youngest Child Of Parents With More Than One

Nov 9, 2006

Parents can have one or more children. I want to return the youngest child of those parents with more than one child.I have [QryParent&children] that returns all the parents and all the children. I have used this as a sub query in [QryParents>1child]. This uses "In (SELECT [ParentsId] FROM [QryParent&children] As Tmp GROUP BY [ParentsId] HAVING Count(*)>1 )" as the criteria in the ParentId. This returns all parents with more than one child and gives the name and DOB of the child.I now want to return just the youngest child for each parent.An ideas?

View 1 Replies View Related

Queries :: Query Multiple Records Between (Weeks) Where No Record In Child Table?

Jul 1, 2014

I am trying to determine the best method for how to handle this query using Access 2013. I have a clients table that contains the following:

clientID fName lName admissionDate dischargeDate
1 John Doe 05/06/2014 06/27/2014
2 Jane Doe 04/24/2014 05/15/2014
3 Steven Smith 05/15/2014 NULL/Empty
4 Chris Davis 06/12/2014 NULL/Empty

Then there is a WeeklyProgressNotes table that is there for the person that is responsible for auditing the clients charts. It does not contain the actual weeklyprogressnotes, it only contains a Yes/No field and a date field for the date the weeklyprogressnote was completed. Like below:

noteID completed dateCompleted clientID
1 yes 05/08/2014 1
2 yes 05/14/2014 1
3 yes 04/25/2014 2

I am creating a form that the auditor can open to determine what weeks she needs to check for each client to see if they have their weeklyprogressnotes completed that week. The weeks run Mon - Sun and there will be no record in the WeeklyProgressNotes table if she has not yet checked and confirmed for that week. So the form would basically look like this:

fName lName week completed date clientID(hidden)
John Doe 5/19/14-5/25/14 Checkbox Null 1
John Doe 5/26/14-6/1/14 Checkbox Null 1
John Doe 6/2/14-6/8/14 Checkbox Null 1
John Doe 6/9/14-6/15/14 Checkbox Null 1
John Doe 6/16/14-6/22/14 Checkbox Null 1
John Doe 6/23/14-6/29/14 Checkbox Null 1
Jane Doe 4/28/14-5/4/14 Checkbox Null 2
and so on.......

I have thought about creating an SQL statement to select all of the clients and then creating a function that determines their admission date within the specific week and their discharge date withing the specific week and then create a loop with another SQL statement with a BETWEEN clause for all the weeks and determine if there is an entry in the WeeklyProgressNotes table or not. If not then I would display out the above info. I'm not sure if there is an easier, less search intensive way of doing it. Maybe an SQL query that can cut done on some of the looping.

View 5 Replies View Related

Forms :: Add Multiple Records At Once To A Child Table From A Form?

Apr 16, 2015

I have an unbound new contact data entry form that adds records to many different tables. I have no problems adding one record to a child table at a time, but one of the things we are collecting is a list of online networks a person belongs to, and I want to be able to stick a "check all that apply box" on my form and have it add multiple records to the child table. Here's the basic set up, I have a parent table with the main contact information with a primary key field "IID", a lookup table with "Facebook, LinkedIn, Twitter..." etc in it with a primary key field "online_id", and a bridge table to link the two which should have multiple entries for IID, one for each online_id. I want to use a listbox (or something like it) that the user can select multiple online networks and then have records added to the bridge table. I can figure out how to add the listbox on the form, what I can't figure out is how to get the values out of the listbox. T

View 13 Replies View Related

Modules & VBA :: Parent Table Revision History - Insert Multiple Records Into Child Table

Sep 8, 2014

I have a parent table (tblLabels) and a child table (tblRevision) where the revision history for the parent table is kept.

The parent table is populated via an excel import and may have several records imported at once. Instead of having the user manually enter a new record note in the child table for each record imported into the parent table, I've created a form that collects the necessary data (date, person who added the record, person who authorized the record, and notes) and then creates a revision history for each new record.

This is what I have so far:

Code:

Private Sub cmdAddNotes_Click()
Dim strSQL As String
Dim RevisionDate As String
Dim RevisionRevisedBy As String
Dim RevisionDesc As String

[Code] ....

When I run the code nothing happens. No error, no new records create, etc. My suspicion is that I may need to use an INSERT INTO query instead of an UPDATE query, but I'm not sure how to go about matching up the foreign keys if that's the case.

View 14 Replies View Related

Queries :: How To Count Records Based On Multiple Criteria From Multiple Tables

Jan 4, 2014

I need to count records based on multiple criteria from two different tables. I have two tables (i.e. "tblTasks" and "tblTaskHistory"). The tables have a one-to-many relationship based on the "TaskID" field. "tblTasks" has a field called "AssignedTo" and "tblTaskHistory" has a field called "TaskStatus". I need to know how many tasks have been "reopened", the "reopened" status is located in the "TaskStatus" field in "tblTaskHistory". I need this count against a unique listing of employees which can be found in the "AssignedTo" field in "tblTasks".

View 4 Replies View Related

Delete Record Only If Child Records Don't Exist

Aug 6, 2005

Hi,

I'm trying to have a button on a form that would delete a record from a table only if there are no child records linked to it.

If there are child records for the selected record, the button would be disabled.

Is there a simple way of doing this?

TIA.

View 3 Replies View Related

Duplicating Parent And Related Child Records

Dec 18, 2006

I am creating a purchase request form for my company. The main form contains the PO Request # (autonumber) and general vendor and shipping information. The subform contains the item numbers on the order, the quantity and costs. What I am trying to do is make it so that users can click a "duplicate" button on the main form of an existing PO Request and have all the data replicated into a new PO Request. A lot of what we order is repetitious and it would time saving if users could just duplicate an order and modify as necessary. Can anyone help me with this one...
Thanks!:confused:

View 2 Replies View Related

Updating Query Flag If Child Records Exists

Jul 12, 2006

I have a stock-type record and a stock-item record.
I want to update a flag on the stock-type record called instock to be true if there are related stock-item records and false if there are no related records.
Does anyone know how to run a updating query that will do this?
I am fairly new to this so I'm sorry if this is a bit of a basic question.
Thank you for your help in advance.

John

View 1 Replies View Related

Queries :: Put Multiple Records In Multiple Columns

Jul 31, 2013

I have three tables. Risk, Names and RiskAndNamesJunction table. I have the junction table because I have many to many relation (meaning many people can be connected to one risk and many risks can be connected to one people).

The problem is that If I make a query to show the people related to the risks, if there are many people for one risk then it will put the people in different rows. Meaning that for risk 2 I will have three rows, because there are three people connected to this rows. See the attached file!

What I would like to do is to have a query which (in case there are more than one risk owners) puts the second name in another column, the third name in another column and so on. So I will have only one row per risks.

The attached file is a dummy file, so there are only maximum three names per risk. In the real file the maximum is five names per risk. So I am talking about no more then five extra columns. (So I am talking about a query which would put the first finding in the first extra column, then the second item in the second and so on till five. It there is no third or fourth or fifht item then the columns remain blank).

Unfortunately I have to do this because our mother company works with excel and they are sticking to this format in excel.

See the attached file ....

View 2 Replies View Related

My Parents

Oct 22, 2006

Hello all,

It is my first post :) (http://1universityofphoenix.blogspot.com)

I want your thoughts on this:
Do you feel that because your parents may have supported you when you were younger, that you "owe" it to them to support them now?


(Pay the bills they run up etc, just because they did it for you when you were younger and unable to work)


Thanks. :) (http://buyamoxicillin.blogspot.com)

View 1 Replies View Related

Queries :: Merge Two Child Fields As String

Jan 14, 2014

I am currently creating a database for lift inspections. The output is a mail-merge report. What I am trying to do is get the multiple Lift Name (child) and Floors Served (child) combined into a string so that each Lift Group (parent) inspection has only one row. This then means that each lift group inspection will be shown as one record in mail merge.

Current

Lift Group ID - Date of Inspection - Lift Name - Floors Served
34 - 14/01/14 - Lift 1 - G-1
34 - 14/01/14 - Lift 2 - 1-3
35 - 14/01/14 - Lift 3 - G-8
34 - 14/01/13 - Lift 1 - G-1
34 - 10/10/13 - Lift 2 - 1-3

Desired:

Lift Group ID - Date of Inspection - Floors Served
34 - 14/01/14 - Lift 1 G-13; Lift 2 1-3
35 - 14/01/14 - Lift 3 G-8
34 - 10/10/13 - Lift 1 G-13; Lift 2 1-3

View 14 Replies View Related

Queries :: Parent Child Query - Sum Images In Main Record

Oct 15, 2014

I'm trying to create a capacity report for my database. Originally, I only had the one table, which summed the number of Packs and number of Images, worked out percentage capacity used and then put it in a report, showing for each week of the year. However since then, I've added a child table to this, allowing me to create subrecords. The reason we did this was so we could easily group together multiple mailings under one single master record, so to speak.

Going back to the capacity, I've managed to work it so the Pack capacity is worked out from the mailing quantity in the subrecord. However, the number of Images is only entered onto the Parent record. Now my capacity query is summing the same number of images as there are subrecords, where in reality I only want it to sum the Images in the main record. I know I could add an Images field to the child table and work it out the same way, but I'd rather not do that (because that's not how our business works).

So essentially the question is, how can I sum the Images from the parent table without repeating the sum and massively overexagerating the sum?

View 6 Replies View Related

Multiple Queries - Certain Records Missing

Jan 14, 2007

Hello again

Sorry, just posted this in reports, moved it now.

Could someone point me in the right direction please. I have seen a thread similar to this before but I can't find it now.

I have a query that is made up from 3 different queries.

These 3 queries show the stats totals in the last x weeks.

qry2Week (colleague stats from last 2 Weeks)
qry6Week (colleague stats from last 6 Weeks)
qry13Week (colleague stats from last 13 Weeks)

This query shows every day and also the above 3 queries are linked in.
qryAll (every day and 2, 6, 13week stats totals)

The problem is if there are no stats in the last 2 weeks no stats will show up at all.

If I take out the (is not null) from the individual queries I get duplicate lines in my main query (qryAll)

How do I show all the information without having duplicate lines.

Cheers

Kev.

View 3 Replies View Related

Queries :: Returning Multiple Records

Feb 17, 2015

I have a sub report that is based on a query. The Where clause of my SQL is giving me a bit of hang up. What I am attempting to do is return the records that are the items used to test products we test. The ID's of the records are gathered in a public function. The function is called GetCal Equipment. This returns all of the requested numbers just fine. For example ID numbers 4, 112, 124, 138, 232, 338 are returned when I call the function. Any number of records can be returned at any point. This is the unique numbers used to identify the records. I thought by having the function return the numbers the records would come up. However when I use that in my where statement, none of the records are returned. The whole SQL is as follows:

Code:
SELECT CalibratedEquipmentListTable.ID, CalibratedEquipmentListTable.Manufacturer, CalibratedEquipmentListTable.ModelNo, CalibratedEquipmentListTable.Description, CalibratedEquipmentListTable.SerNo, CalibratedEquipmentListTable.LastCal, CalibratedEquipmentListTable.CalDue
FROM CalibratedEquipmentListTable
WHERE CalibratedEquipmentListTable.ID In (GetCalEquipment());

how to get the query for the report to return the records.

View 10 Replies View Related

Queries :: Multiple Records Selection

Jun 13, 2014

I have a database that contains different departments per office location with the dept. codes such as 100, 101, 102, 103 etc.

I like to have a criteria in a query that will give me all departments that are running from one office location OR if I do not want one dept. to show in my query to be excluded.

Also, the way I currently set the parameters is, it is asking for the office location by state, county, city, address and department code. I set the department criteria as Not [Department] which excludes the dept. that I do not want to see in the query, BUT I also want to have an option that when I run the query to SEE all the departments.

Is it possible to have a criteria like that?

View 3 Replies View Related

Queries :: How To Get Multiple Records To Show As One

May 4, 2013

I have a query which is supposed to show the revenue from each advertising source.

PLease see attached in zip file (cant post pics b/c I have less than 10 posts)

As you can see it has revenue amounts for the same source of advertising:

Radio has two amounts, INternet has two etc..

What can I do to only have each form of advertising show up once?

and the revenue amounts summed up for each advertising medium.

View 2 Replies View Related

Retriving Duplicate Records With Multiple Queries

Aug 18, 2005

when running the attached report I am getting duplicate records. If using the protocol specified tc02026 there should be 8 records total. When running the report it pulls from both queries which have select criteria. How do I limit the report to only give me the 8 records and eliminate the duplicates? When I run each query it only gives me the 8 records I am looking for. Each Sample# in the report is a unique number(to help see the replicates).

Thanks

View 1 Replies View Related

Queries :: Multiple Records Appear In Output Of Query

Mar 4, 2015

i have got 2 tables i am trying query against. in table 1 i have a list of records which only appear once in the table under 1 field. in table 2 list of records which may have the same record appear under the same field numerous of times with different data in other fields on the table. i have created the reationship between both tables but i am getting multiple records appear in the output of the query where i only want the record to appear once in the output.

View 2 Replies View Related

Queries :: Copying Multiple Records From One Table To Another

Sep 7, 2013

I'm using Access 2007.I have 2 tables that are identical in structure.The tables are called [Workorder Parts] and [Workorder Parts Temp]. They both have the same structure:

WorkOrderPartID (Autonumber)
WorkorderID(Number)
PartID(Number)
Quantity(Number)
UnitPrice(Currency)
Notes(Memo)
KitID(Number).

[Workorder Parts] has 128 records in in and [Workorder Parts Temp] has 28 records in it that are a small subset of [Workorder Parts] therefore, the contents of the key field column in [Workorder Parts Temp] is the same as in [Workorder Parts].I tried the following SQL but get an error message saying "Cannot Update "WorkOrderPartID" Field not updateable":

DoCmd.RunSQL "INSERT INTO [WorkOrder Parts] SELECT * FROM [Workorder Parts Temp]"

My aim is that I want all of the records from [Workorder Parts Temp]to be copied to [Workorder Parts] and have their "WorkOrderPartID" fields correctly updated with a new value...

View 14 Replies View Related

Queries :: Subtract Two Fields From Multiple Records

Sep 5, 2014

I have the following source data:

Code:
Item Revision Start End
332 B 9/2/11 9/15/11
332 C 9/21/11 9/22/11
332 E 11/2/12 11/29/12
2A9 A 1/13/13 1/14/13
2A9 C 1/16/13 1/18/13

I'm trying to make a select query to provide the following output (RevisionStart-PreviousRevisionEnd):

Code:
Item Revision Span
332 C 6
332 E 407
2A9 C 2

I've struck out with union queries and aggregating/sorting letters and don't know where else to look. Is there a specific name for this type of operation anyway?

View 4 Replies View Related

Queries :: UPDATE Multiple Records In Same Column

Jan 16, 2015

I am trying to run below to update multiple records in the same column and get error message saying characters found after end of SQL statement. I tried to remove ; but then get a syntax error.

Code:
UPDATE [tblMonthly] SET [Date] = #20130701# where [File] = 'A';
UPDATE [tblMonthly] SET [Date] = #20130801# where [File] = 'B';

View 4 Replies View Related

Queries :: Cumulative Total On Multiple Records?

Mar 28, 2014

I am looking for a way to get a progressive cumulative total from daily entries on Odometer records from multiple vehicles. (My current SQL query is not working) I will eventually run a report from these between two dates. I found the thread here, but am unsure of how to implement this - if this is indeed what I need in lieu of my current code..?

[URL]

My current problem is that, not all my previous entries are correct; Im not sure what is happening to the numbers about halfway through...

For clarification, here is my current code and an example of what is needed. The issue is highlighted in yellow. Excel shows the correct calculation

Code:
SELECT qry_ODO_Table.ID AS OdomAlias, qry_ODO_Table.ODate, qry_ODO_Table.VehicleNum, Nz(DFirst("Odometer","qry_ODO_Table"),0) AS StartOD, Nz(DLast("Odometer","qry_ODO_Table","[ID] < " & [OdomAlias]),0) AS Previous, qry_ODO_Table.Odometer, [Odometer]-[Previous] AS Difference
FROM qry_ODO_Table
ORDER BY qry_ODO_Table.ID;

View 12 Replies View Related

General :: Creating Multiple Records (with Queries)

Jul 19, 2012

I'm working on a contact database for my company's sales efforts. It tracks interactions with prospective customers and assigns them to employees here. My question is this: For mass contact efforts (such as mailings), is there a way to create mass entries to my "Interactions" table so that no one has to enter a mailout interaction 1000+ times?

Structure of the relevant bits of the database is as follows:

Contacts Table
Interaction Table

Contacts Table is linked with Interaction table via ContactID

Queries are run to narrow Contacts by various criteria (ex.: by the employee they're assigned to).

So if I run a query to get all the contacts assigned to me, and there are 450 of them, and I send a mailout to all of them, and I want to add an interaction to those 450 people, is there an automated way to do this?

View 5 Replies View Related

Change Colour Of Entry To Differentiate Between Students And Parents Results?

Oct 7, 2011

I have a large database of students and parents which charts their weight, waist circ., lifestyle etc. When I then create reports, is it possible to change the colour of the entry so that I can differentiate between students and parents results? In other words, can I have all student entries in red and all parents in black, for example? At the moment, when I try to change the colour of one of these, the entire column changes to that colour and I don't know how to amend my reports to do this. Please see attached.

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved