Microsoft Access 2010: Update a field in another table on button click - ms-access

Basics about the database
I am working on a (relatively) simple database that stores inventory data. I am using Microsoft Access 2010 in order to do this. I have six tables with the following relationships:
Relationships of Database
I have created forms which combine the Transaction table with Ordered, Received, Allocated, or Dispensed. Each form requests an amount which will then be used to update On Hand, On Order, or Allocated (from the Material table) respectively.
The Problem
For example, my form to update Transaction and Order should be able to take in the Amount ordered, save all the data from the fields to the Transaction and Order tables as well as add the amount from Amount to On Order in the Materials table.
I have been working on this database for the past two days. I have searched several times for possible ways to perform a similar function, but have come up with nothing. All the tutorials I have found which seem remotely close to what I need to accomplish are for versions of Access which are much older than 2010. Unfortunately I have had little experience with the actual coding within Access, so I am stuck clicking around within the buttons on its menus.
What I have tried
Currently, the program is set to run the following Update query:
Screenshot of update query
This query works if I have one Material stored in the database but adds all the Amount values from Ordered to On Order every time it is ran, which is unfortunately not what I need it to do. I only need each Amount value added to On Order once.

You need to relate the Ordered and Material tables by adding a foreign key field to the Material table, ex. OrderedFK (Long Integer). This new field must be updated whenever a row is inserted into the Ordered table (assuming the "No" Field is AutoNumber). This is typically performed by using a Form (Ordered) and Sub-Form (Material) and setting the sub-form' Link Master (No) and Link Child fields (OrderedFK).
You can then join the Ordered and Material tables on the Update Query to achieve the desired result.

Related

Subtables in MS Access

I am working on a database that has one main table with the entry rows having an individual table for calculations.
So I have about 9 tables that have calculations /values in that are associated with an individual indicator field entry in my main table. I would like to link the calculation tables to the individual entry.
The subdatasheet allows me to do this. However, it populates all the entries with the same table which I do not want as one calculation table is only associated to one entry.
I can’t create one table for all calculations as they have different types of data and are calculated differently so I can’t link with regards to relationships.
The only solution I can think of is by populating a new field called “results calculations” and populate it with the title of the calculation table associated to the individual entry.
Is there another way I would love all the data to be as accessible in one table as simplified as possible.
(I am new to MS Access so any advice will be appreciated.)
The result of using subdatasheet
What I need to link to each indicator

In MS Access 2016, can you create a checkbox or yes/no field that synchronizes with other checkboxes that meet a certain criteria?

Picture of my relevant fields simplified for this example:
I am currently working on updating a database in Access for work that has more or less been just a spreadsheet up to this point. As such, I have a lot of information stored on a single table and I'm looking to avoid creating new tables that have to be manually filled in if possible. I track our purchases, confirming whether or not all the items on a particular purchase order or "PO" has come in, or if that PO only came in with a partial shipment. This database does not track POs as they are created, only as they are received by shipping, so I do not have a separate table that lists all the POs.
I am trying to create checkboxes in my table that synchronize with other checkboxes of the same PO, so when I receive the final shipment in for a PO, I can click "Order Complete?" (see linked image above) and all of the checkboxes with that same PO# will also be selected.
So far, in my fairly limited Access knowledge, I have attempted to make a new table from a query that listed only shipments with PO#s and then removed duplicate PO#s. I put the same "Order Complete?" field in the new table and then linked the PO# field on both tables and the Order Complete? field on both tables, but this didn't match them up. My coding knowledge is fairly limited and a little rusty so I was wondering if there was any simple way to do this without a really deep dive into coding.

Why are my records not being inserted in the same order they are being executed?

I'm using Microsoft Office Access as my DBMS and I'm using VBA to write my code for this project.
I'm doing data scraping for items on a website and I encountered something that appeared odd to me after I had inserted my data into a table.
In my code I use a loop to iterate through and collect all the items that the website has to offer. Once I have all the data for one item I insert it into my table and then move on to the next. There's 14,724 items that I need to insert into my table. If I iterate over all of them, they will be added to the table but they are out of order once I look at them in the table, even though all the items are there, however if I adjust the loop to only collect...let's say only the first 10 items then they will appear in the same order in which they were collected which is the same order they appear in the source code for the website.
It is important to note that my table does not have an id field because it is not required as there's one other field that serves as a unique identifier for an item in the table.
This does not seem like a big issue but I'm curious as to why this happens. Is there some kind of limitation when using MS-Access as your DBMS?
Any insight is greatly appreciated.
Thank you.
A table is not a spreadsheet.
This is by design of any relational database engine. Records in a table have no order other than what you eventually assign or apply.
If you want to sort the data (ascending or descending) use a Query. The Table doesn't have any order. Even the Fields don't have any relevant order.

Is it possible for MySQL to "auto-update" a field whenever changes are made in another, unrelated table?

Let's say that we have one table with a field called sales_total and another table with a bunch of sales entries. Let's also, for a moment, imagine that it is impractical to count the entries every time we want to see the total number of sales.
Is it possible to have MySQL automatically update the sales_total field every time the number of sales entries changes?
I know that you can do this by running another query via C#, PHP or whatever - I'm just curious whether MySQL (or some other database system) can do this within itself?
P.S. This is of course a pretty banal example - the ideal solution should be able to handle more complex operations (storing several rows as a string in a field, etc).
use mysql trigger...
trigger on update from the first table should have some queries to update the second table.

Access Form Field Logic

I'm trying to make access conditionally only show rows that meet a certain condition, allow me to give you some background info before I proceed :
I've created an Access form and linked it to a test DB on my machine. The particular table I am interested in contains the following (important) rows :
ID , Office, Name, SecurityNumber
The thing is, ID is not unique. There are two Office locations, and each Office has it's own set of unique ID numbers. This means that ID 10 here and there may or may not be the same person. (this data comes out of a legacy security system we're not looking to change yet, so I cannot change it)
But ID -is- unique to each Office.
SO! I created an Access form with TABS! Two tabs, one for each office. What I am trying to achieve now is :
Have the ID/Name/SecurityNumber fields for each tab populate with only rows that match it's particular 'Office' value.
Thank you for reading and thank you for helping! :D
If you want the data for the office locations presented in separate tab page controls, you could use subforms on the pages which differ only in the WHERE clause of the queries used as their record sources. So for the Office1 subform, the query could be:
SELECT ID, Office, [Name], SecurityNumber
FROM YourTable
WHERE Office = 'Office1'
ORDER BY [Name];
Then for Office2, the query would be the same except for the WHERE clause:
WHERE Office = 'Office2'
As I understand your question, that approach would do what you're asking for.
However, that's not really the easy "Access way" to do it. Instead consider a combo box control to allow your users to choose which office they want to view. In the code for the combo's after update event, either modify the SELECT statement used as the form's record source or create a filter expression an apply it.
Also, since you're pulling the form's data from SQL Server, consider whether you want your form to load every record for the selected office location. It may not be much concern if you have only a few to moderate number of rows for each location, but if you'll be dealing with multiple thousands of rows it could be. In general, you should try to avoid pulling copious amounts of data across the wire; pull sparingly instead ... only what you need for the immediate task at hand.