Access: Appending Related Tables - ms-access

I am working on a small side project. Below is an image of all my relations. I only have the tables set up so far, and a couple Queries that sorted my a couple of my tables a certain way to be used as lookup columns.
Is there a way to append new records to multiple tables at once?
I have experimented with this a few different ways. The thing that stumps me is when I create a form and corresponding sub forms (I can make sub form after sub form that has the entire string of things that could be input across multiple tables, which is not very aesthetically pleasing or easy to use), I have to enter data multiple times. Referring to appending the invoice item as well as the item list tables. I would have to enter the following;
Invoice Number (From invoice item)
Item Code (From invoice item)
Item Code (From item list)
So I end up having to type the item code multiple times, this occurs across the entire chain of tables I need to update in order to create an order.
Also in case you are wondering, all the tables seen in the diagram are update at time a new order is created. (This is a resale business so inventory is never held and item (in the Item List table) are added new at time of order.
So the Invoice table needs to be appended which starts the chain that I am trying to accomplish. Invoice number gets entered which I would like to automatically carry over to Invoice Item in wait for the Item Code to be entered to complete the composite key but without having to type the Invoice number again, and so on and so forth.

This is referred to as a Cascading Update and is essential to enforcing Referential Integrity.
What you want to do is:
Click the relationship line for the relationship that you want to
change. The relationship line appears thicker when it is selected.
Double-click the relationship line. –or– On the Design tab, in the Tools group, click Edit Relationships.
The Edit Relationships dialog box appears.
Select the Enforce Referential Integrity check box.
Select either the Cascade Update Related Fields or Cascade Delete
Related Records check box, or select both.

Related

How to Design Query for Two Tables Not Directly Related

With my limited knowledge of Access, I have been struggling to figure this one out.
I have 4 tables. tblJobDetails, tblDrawings, tblDrawingFixtureType and tblFixtureType. They are related to each other in that order.
What I have been trying to do is a query based from tblFixtureType. I want my users to have a datasheet where they can input all the fixture types for the given job, but keep them under that particular JobID. I have not had much luck in that department. All queries I have made either show every single type entered in the DB, or nothing.
The JobID is the PK for tblJobDetails and is a FK in tblDrawings. tblDrawingFixtureType is intermediate/junction table that is meant to hold quantities, but has DrawingID and TypeID as its FK's.
So how would I correctly build a query for my users to input all fixture types (designations), but keep them assigned/filtered under that particular JobID?
I am sure more info will probably be needed, so please ask.
You don't build a query to solve this problem. What you do is build a form based on each separate table.
In Access you model the parent to child relationships by using form + sub-form combos.
So, you might have a form that say lists out job (continues form).
You click on a row, and then launch a form with a nice display of the job details, and then in the sub form, you allow entry of tblDrawings.
The sub form will hook up the FK. And to edit/select the tblDrawingFixtureType, that drives a combo box in that sub form to select the fixture type, and it will save the PK of FixtureType in the one column.
All and any of each form (or even the sub form) is to be based on ONE table, and NOT a query. You don't edit data in tables, you build a form based on the table. If there is child records to add to that one record, then you build a sub form (and again, that sub form is based on ONE table).
Not only does this mean you don't have to create any queries, but you also don't have to write any code since when using a form + sub form, you get editing of related data that way.

MS ACCESS Managing deletions with one-to-one relationship

I have a working Sales Order form, and I need to add a subform for Returned Goods. I have a one-to-one relationship set up between the ID of my SalesOrderDetails and my SalesOrderReturns, because each line item should never have more than one SalesOrderReturn line item.
I want to be able to delete SalesOrderReturns from the subform datasheet, while not deleting the SalesOrderDetail it's tied to. Let's say it was entered on accident. On the other hand I want to prevent deletion of the SalesOrderDetail if it's tied to a SalesOrderReturn.
The way I have it set up now, I cannot delete SalesOrderDetails if they have a linked SalesOrderReturn. But when I delete the SalesOrderReturn, it deletes the line item in SalesOrderDetails. I just want to remove the Return without removing the line item.

How to edit an existing record and not create a new one when using subforms in Access?

I have an access database that holds medical information. It holds quite a bit of information so i have grouped like fields together into individual tables and linked them using a common primary key. I have created a tab style form with subforms on each tab.
Some of these subforms contain fields from only one table, however there are a few subforms where i have included fields from more than one table.
For example, i have a table that holds blood transfusion data and a table that holds patient characteristics. Some Fields from the blood transfusion table and patient characteristics table are in the same subform, but I also have fields from both these tables in other subforms.
When i try to insert data into the sub-forms with fields from multiple tables i get the following errors..
update or cancelupdate without addnew or edit
and
The changes you requested to the table were not successful because
they would create duplicate values in the index, primary key or
relationship. Change the data in the field or fields that contain
duplicate data, remove the index, or redefine the index to permit
duplicate entries and try again.
From researching the problem i gather this is because access is trying to create a new record for both tables, but if a record has already been created with that primary key (from inserting data into a previous subform) it won't edit the existing record.
Does anyone know how to get access to edit the existing record in this instance instead of trying to add a new record? I have basic skills in VBA but this is a bit past my level of experience.
Any suggestions would be greatly appreciated.
I used have a whole long response about split forms instead but I was having a horrible time getting it to work. So here is my new and improved answer for using subforms.
Here is a link with sub form info if you want to brush up for your purposes https://support.office.com/en-us/article/Create-a-form-that-contains-a-subform-a-one-to-many-form-ddf3822f-8aba-49cb-831a-1e74d6f5f06b
Step 1
Make sure your main form is bound to the right table.
For my purposes I used a single combo box on my main form to search with. Make sure all the field parameters on your combo box are correct. This includes making sure the Row Source is correct and that you DO NOT have a control source entered.
Step 2
Don't press enter after making a selection in the combo box. To prevent people from hitting enter I created a dummy button at the bottom that says "Save and Refresh" but all it does it create a message window that pops up with "Save Successful". I find hitting enter creates the first error you keep getting. I'm not sure how to address this in a more sophisticated way yet.
Anything else that comes up I will add later.

Determine whether row is selected in MS Access 2007 List Box

I have a situation where I want to associate multiple values from one table with a value from another. I've got my data structured with a many-to-many join table in between, and I'm trying to manage the membership in the join table.
This question is about the UI portion of the process. I think that what I want to do is to present the user with a multi-select List Box control on a form that holds the ID of TableA constant (and, incidentally, hidden). The List would be populated with all the (fairly short list of) rows from TableB (descriptions displayed, IDs in hidden column). On load, I'd select those rows of the list that participate in the M-M join. The user could select additions and/or deselect removals.
What I'm not sure about is how to tell whether or not any given row is selected. I know about the IsSelected collection--if I were just adding, I'd walk that with For Each, but I need to remove any that have been deselected, and I need to not re-add any that already exist. What I'm thinking at this point is walking the whole list, testing each selected value & inserting it if not already present, and testing each un-selected value for possible deletion (hmmm--that's starting to sound needlessly complex....).
What I started out to ask was "how do I tell if row(x) is selected?" I'd still like the answer to that, but I'm open to other suggestions for managing the base problem, as well
In seems that you have a list that you are using to create the selected items. After the user has updated the list box, you can compare .ItemsSelected to the rows of the list that participate in the M-M join. Missing items can be deleted and additional items can be added. A few very rough notes:
For Each itm In Me.AList.ItemsSelected
rsJoinList.Find "ID=" & Me.AList.Column(0, itm)
If rsJoinList.NoMatch Then
'To be added
Else
'To be deleted
End If
Next

Best way to create a form that changes and gets information from multiple tables and queries

I've been pondering this for a couple of days now, i have a relatively large database with multiple tables, and my goal is to be able to administrate this with a MS-Access application. This is the workflow that i want to achieve:
1. Choose a category of products
2. Choose a specific price list.
3. This lists all products of that category in this price list.
4. Choose an item in the list a
5. this triggers an update in a subform and fetches the data related to the choosen row
6. Choose the price in the subform for that specific type.
This problem triggers some newbie questions:
1. How do i trigger an update in a datasheet from a drop down list, so that the datasheet only fetches products related to that category?
2. How do i make a subform trigger yet another subform to update?
And third but not least
3. Is there any good tutorials or other study material out there?
If theres anything that is unclear please tell me and i will try to clarify the questions, english is not my native language. :)
Access will do a lot without any code at all. For example, if your categories are listed in a listbox, that can be made to cascade to a second list box that shows only relevant price lists. Subforms have link child and link master fields that can refer to fields (columns) or controls. You can have a subset of records in the subform where the link master field(s) are the listbox(es) and the link child field(s) are the relevant related field(s). You can also refer to subform controls in link child and master fields.
You might like to look at the Northwind sample database that ships with all versions of Access, in particular, the Customer Order form.