Insert row into table when checkbox is checked - ms-access

I have a MS Access db to handle our product pricing. One of my tables has all of our products in it with a yes/no, "checkbox", field field to identify if we bulk that product. I have a separate table that handles our bulk product pricing. Currently when I want to set up a bulk product I add it to our products table, check off the bulked so it removes it from the non-bulk price query, then add the product# to the bulk products table.
I'm pretty new to VBA but what I want is when the "Bulked" field is checked it takes the product code for the current row and insert it into the product code field in Bulked Products. Is that possible?

Yes, it is possible, you can run an update query in VBA, but I suggest that you do not do it. It will involve you checking whether the record already exists in the bulk table, if it does exists, if it matches, and rewinding if someone clicks by mistake. I do not believe you need two tables, you just need a field to indicate that the product is bulk.

Related

I need to link separate table IDs

I have a dashboard where I can update, delete and create. I have 3 separated tables, Developers, Absent, Date.
Developers contains developer names and personal information. Absent is used for a segment of code, basically on certain days someone is absent. Date is mostly the same but this is for holidays instead.
I joined tables, so absent.absent_id=developers.absent_id, date.date_id=developers.date_id
When I create a developer I need to insert values. HOWEVER, I'm having a problem. The IDs of the tables need to be manually inputed through the database. I would like it so that If I create a new developer on the dashboard using Insert, The absent_id and date_id are ID linked between tables.
In short:
If create developer on submit, Add new Auto-incremented ID row to all 3 tables. Anyway this can be done?
You can achieve it with 3 SQL request, first insert new Developer and return its ID, use that to insert a new row in Absent Table and also return its ID, use both IDs to create Date row, i don't think it's related to Front-end(React) but rather a backend.
Cheers.

Best way to update rows in table

I have an interface where the user adds, edit or delete products, once I save the changes I go to the products table, delete everything by ID and add the products that the user just selected, is this a bad way? how could I better thank you
Yes! it's a bad way cause every time you perform two tasks instead of one. like if you want to update product you can update it directly using UPDATE query rather than delete and then insert
What will be the benefit of this UPDATE
Query will be easier
you can get result in single query
if you have id it will be the same rather than changing every time cause you insert new record every time
Ex: think that you are making an e-commerce website a user visits your website and added the product in his/her cart but doesn't check out at that time. it saved it for later meanwhile you change the details of your product so you removed old id and inserted the new one.
now what's happens when user check his/her cart it will not show the product or some sort of error will generated as you have created your e-commerce platform so using update is far more better then delete-insert process for editing the product
Syntax:
UPDATE TABLE_NAME SET COLUMNS_NAME=NEW_VALUE [where clause]
Ex:
UPDATE PRODUCT SET product_name='HELLO WORLD' where id=1

MySQL find lowest price of multiple products in multiple tables

I have a database called Pricelist. In it there are several tables eg. Store1, store2, etc. Each has a list of the products. Most products exist in each store but some only exits in one or two stores. I want to have something that I can run within SQL (stored procedure?) That will find the lowest price of a product by checking the price from each store and then when it finds the lowest price, it will get that price, along with the UPC,Description, and other columns and put all that information in a final table called BestPrices. Then it do it all again for each product in every store. So when it's done. every product from all the stores should be listed once in the BestPrices table with the lowest price and the additional information from the other columns I chose. Is this possible? I know it's a lot. Thanks in advance.
You can create temporary/buffer table to collect data from tables store, then you can query from that table to get the lowest price.
If all you want is display the best prices, then an SQL View should do the trick. A View is enough to
find the lowest price of a product by checking the price from each
store ... along with other columns and ... do it all again for each
product in every store.
However, an SQL View is rendered at runtime and hence, you do not have the values stored in a table, per se. That is, the best prices are calculated as and when you invoke the view
If you want to have the values stored for future viewing, then you shall need a Stored Procedure which shall insert the values into a physical table.
In the case of using a procedure, you should take care as to what should happen to the existing data when you insert into the table.
Also, your post doesn't include details regarding the actual table structure or the common identifier for the product across all the tables. Those details can greatly influence the design and performance of the View/Procedure.

Need help on Mysql Database Structure

I have 200 users each user will eventually have a "reviewINFO" table with certain data.
Each user will have a review every 3 to 4 months
So for every review, it creates a new row inside the "reviewINFO" table.
This is where i'm stuck. I'm not sure if I need to serialize a table inside each row or not.
Example:
-> links
"USER1reviewINFO"-row1->USER1table1
-row2->USER1table2
-row3->USER1table3
-row4->USER1table4
-row5->USER1table5
"USER2reviewINFO"-row1->USER2table1
-row2->USER2table2
-row3->USER2table3
-row4->USER2table4
-row5->USER2table5
using this method it will make a couple of thousand rows within two years. And I think its harder to manage.
"Userxtablex" is a table with dynamic rows of children names,ages,boolean
What i'm think of doing is serialize each USERxtable into its corresponding row.
Please help as I would not like to make this complicate or inefficient
Generally, you should never have to serialize data of this nature into a table row to accomplish what your goal is (which I am assuming is an implicit link between a user and a review)
What you need to do is key the reviews by a user_id such that all the reviews are packaged in one table, and relate numerically back to the users table.
Assuming you have an AUTO_INCREMENT primary key in the user table, all you would need is a user_id field in the reviews table that represents what user the review relates to. There is no need for a separate structure for each user, if that's what you are suggesting. Reviews can have date fields as well, so you can perform queries for a specific year or window of time.
You can then use a JOIN query to select out your data set relating to a particular user or review, and apply the usual WHERE clause to determine what result set you want to fetch.

MySQL table design

I have a table with products. Each product has a title and a price.
The products come in huge XML files, on a daily basis.
I store all of them in MySQL. But sometimes they have a wrong title. But i can't edit it, because they will be lost the next day (cronjob removes all products and inserts again).
What would be the best way to edit them? Save them in a different table and SELECT both tables at once? Whereas the table that contains the edited rows has precedence over the cronjob table.
What would be the best way to handle it, since there are 300.000+ products. Products might be (manually) edited via a CMS system.
Thanks!
Is there some sort of ID that remains constant? (productID) for example?
Can you edit the cronjob?
If both of the above is true; i'd edit the job to only add new records into the table; preventing writing over your updated values.
If there is a unique identifier for each product that remains constant over updates, you could make a table containing the product ID and the corrected title. Correcting a title would involve inserting a row into this table as well as updating the main table.
As the last step of the cron job, you can then update your main table of products from this one.
UPDATE FROM tblProduct p, tblProductCorrections pc
SET p.strTitle = pc.strCorrectedTitle
WHERE p.intId = pc.intProductId