MS access After update - new record in another tab - ms-access

I Try to find the way, how to make AfterUpdate event - to create new record in another (no updated) Table.
I mean, I've got 2 tables:
T_Prices : product_ID, Prices for m2 and package.
T_AllPrices incl. PID, m2, pcg, date.
I try to make event, query or sth, that create new record in T_AllPrices, after I update / change prices in table T_Prices, manually or via query. The New record should include NEW PRICES, so I don't need to use [old].[m2]...
I hope this img will explain it better than I did.
Thank you all for help

search for Table triggers/ data Macro if you are using MS Access >=2010.
A sample answer can be found here: https://stackoverflow.com/a/25722579/1684486

You should never operate on the tables directly.
Use a form (in Datasheetview if you prefer) bound to the T_Prices.
Then use the AfterUpdate event of the form to create the new record in the other table.

Related

Deleting/Copying the data from Database with specific condition in mySQL

I am looking for an Idea to handle data in DB directly.
Here is my use case
I have table “EVENT_REGISTERED” with column (ID, Event_name,Event_DateTime)
I want to display the EVENT_REGISTERED in the fronted end whose date and time is not passed. i.e. I want to display only Upcoming event not Historical events.
Of course this can be handle with JS code before displaying.
But What I want is there should be some sort of a trigger which will delete the Instance form the “EVENT_ REGISTERED” table and copy it to another Table “HISTORICAL_EVENT”
I cannot Create an MY SQL EVENT to do this as it like batch job and I cannot run this every 5 mins as there can be more than 10000 rows in there.
I see Trigger option as well, I am not sure how to use this as it says that it will be activated after the specific action is executed. Here the specific action is CURRENT_DATETIME == EVENT_DATETIME.
Can anybody give me a direction or any sort of alternative way to achieve this?
**I am not an Expert of MySQL*
Thank you
Regards
Prat
Don't start moving rows between tables. Simply run a query:
select er.*
from event_registered
where er.event_datetime > now();
With an index on (event_datetime), performance should be fine.

Use an Access 2010 form based on 1 table to enter data in a linked table

First of all, I am a total NOOB! I am trying to make an Access DB for handling orders through an entire process. As such, I have created tables based on each of the individual processes. The order data, which holds only the basic information is in tblCurrentOrders. Each of the other processes is linked to tblCurrentOrders by the OrderNumber field. The first step of the process is due date information is entered in the tblPlanner table. Obviously, until data is entered in tblPlanner, no OrderNumber exists (this will hold true for the other tables, too, if I ever get that far).
I want to create a form based tblCurrentOrders that shows only the records without corresponding entries in tblPlanner (new orders) and then I want to be able to enter the tblPlanner info in a subform. I have tried making a form based on tblCurrentOrders with a subform based on tblPlanner, but I can't figure out how to only display new orders. I also tried basing the form on a query that only showed new orders, but I don't know how to make the subform based on tblPlanner to work.
Please Help!!
Well, the easiest way to link the tables would be to create your OrderNumber in the tblPlanner when you start a new order. Then add a flag and timestamp as to whether it's "released" yet.
EDIT
Since you provide a little bit more detail, I'll edit my response to more closely align for your desired approach.
Creating a "New Order" is a multi-step process. So it's usually best to create a Command Button on a form that calls VBA code. This will allow you to control each step and make sure it's correct.
Step A: First you want to:
1) Create a Control Form (if you haven't already) that allows you to put Command Buttons which will launch different VBA code or open different display Forms.
2) On the Control Form, create a List Box that allows you to select an existing OrderNumber.
3) On the Control Form, create a Command Button to open an Order Form which uses the selected List Box OrderNumber. When that Order Form opens, it will populate with the tblCurrentOrders data for that OrderNumber and also populate the subform with tblPlanner data. (As long as you have them linked properly.)
4) On the Control Form, create a Command Button to open the Order Form with a set of records which are "New Orders" only. See the more detailed process below in Step C.
5) On the Control Form, create a Command Button to Launch VBA code that will create a "New Order". This is a multi step process detailed below in Step B.
6) Create any other buttons or controls that allow you to monitor or advance your "Order" along the way to completion. (This is a ton of work to get all the pieces in place.)
Step B: When you press the Command Button to create a "New Order" you want to create VBA code that will:
1) Create a new record in the tblCurrentOrders table.
2) Create a Unique OrderNumber on the new Record. It's usually best if you control the generation of this number and don't just let it be a system generated sequence number. But whatever you desire is ok as long as it's Unique.
3) Set your ReleasedFlag to false on the new tblCurrentOrders record.
4) Make sure your ReleasedTimeStamp is null. (Or whatever value you want it to be.)
5) You may want a CreatedTimeStamp which you can populate with a date of Now().
6) Populate any other "Initalization" fields that need to be filled. (Like Backorder status, Return flags, Shorted Flags, etc. etc. etc.)
7) Create a new record in the tblPlanner table.
8) Copy the Unique OrderNumber that you created for the tblCurrentOrders record into the OrderNumber field on the new tblPlanner record. This creates a link for you to use with your subqueries and subforms.
9) Now you can open the Order Form with this new OrderNumber.
Step C: When you press the Command Button to open a set of records which are "New Orders" only:
The Command Button needs to launch a query to find "...tblCurrentOrders that shows only the records without corresponding entries in tblPlanner (new orders)":
You just need to select tblCurrentOrders that have a ReleasedFlag set to false.
`SELECT * FROM tblCurrentOrders WHERE ReleasedFlag = false`
So when you say: "...and then I want to be able to enter the tblPlanner info in a subform"... you can create a subform linking to tblPlanner based on the tblCurrentOrders OrderNumber field.
This is all reliant on you observing that when you say "...records without corresponding entries in tblPlanner..." That you really mean: records without released entries in tblPlanner. And that means: in order for a record to exist in tblCurrentOrders, it has to have a corresponding blank (or starter) record created in tblPlanner. Thus now you can display blank tblPlanner records that are linked to unreleased tblCurrentOrders records.
Then once your data entry people are done monkeying around with the New Order, they can "Release" the order (usually by clicking on a Release Command Button). At that point, you can set your ReleasedTimeStamp to Now() and set your ReleasedFlag to True in the tblCurrentOrders. It's officially no longer a "new order" and is now a live order in your system.
You are at the tip of the iceberg for creating a home grown order entry system. The complexities for building a good one are immense. Best of luck figuring it all out. Just remember to use time stamps and ID fields so you can go back and un-do what may have been done by accident.
Hope this all helps. :)

Filling up a Form to update data table

I have to create a user-friendly form that allows employees to add details regarding a new shop branch to a data table, also in Access. Using only Microsoft Access, a user has to fill up a form with the relevant details so that a new entry will be appended to a data table.
E.g. A new shop branch will have the fields ShopID, ShopName, and PersonInCharge. Upon filling up a form with these 3 details, a user will click a button "Submit". Doing so will create a new entry in a data table.
I have tried linking the button to run a query that updates the data table but no new entries are created. I have also tried using the "Append" function as part of Query Design, but running it would append "0" rows.
Unfortunately I can't take any screenshots since I'm doing this in a company as part of my internship. This is my first time using Microsoft Access. Would appreciate the help!
In my understanding, you just want to make a simple form that simply add a record into your table right?
why don't you create a desired table first then create wizard form on it. It will automatically generate a form as needed then you can add a button using wizard choose categories -> record operations -> add new record.
Hope it helps!

Marking new entries on Microsoft Access form

I'm working on Microsoft Access Database. I have a query contains a 'requery' command on its OnLoad method, so the query will automatically updates a new entry whenever I add new records in a table corresponds to the query. My question is, my supervisor wants me to mark the new updated entry on the query (which already had modified into a form), so the admins will notice that the table has been updated and there are new record included to the form. More likely, some kind of mark the rows that containing new update with different color. Does Microsoft Access has that kind of functionality?
Thank you very much.
There is conditional formatting which you can use to change colours based on data. You could create a field which changes when the row is updated and the colour changes based on this field.
https://support.office.com/en-sg/article/Change-the-appearance-of-a-control-by-using-conditional-formatting-6ba9e9fa-4347-4183-b335-44e43b05e22f
As far as I am aware though, a query doesn't change records, it only pulls existing records. So if you want to highlight new entries you need to do this based on information stored within that record or create a new field for this purpose.

Ms Access, make one table get data from another table in real time

So, i have 2 tables, let's say : Customers and Activity. Customers containing only customers and activity containing customers but also other pieces of information.
I have a form to write data in the Customers table.
What i need is the Activity table to auto-update itself each time I write an entry in the Customers table.
Is it possible to create a relationship between the two tables to do that? Or should I write something at the end of the code I use for the form?
Is it possible for instance to create a function that i call at the end of the code i use for the form?
Thanks.
If you're wanting to automatically update, independently of any form, a table based on changes made to another table, I would recommend a data macro which is new to MS Access 2010. They're pretty cool and are similar to triggers in enterprise level relational database management systems.
Open your Activity table. Under table tools create a named macro called NewRecord. Create a parameter called prmCustomer. Your macro could look like this:
Create a Record In Activity
Alias
SetField
Name Customer
Value = [prmCustomer]
Then open your Customer table. Under table tools create an After Insert Event. Your event could look like this:
RunDataMacro
Macro Name Activity.NewRecord
Parameters
prmCustomer = CustomerID
You'll have to do some playing around since you haven't given much info, but that's the gist of it.