Copy Values from one record to the next on

alexsoft

New member
Local time
Today, 06:37
Joined
Feb 4, 2024
Messages
12
hI, i Am new here so i try to explain my problem. i have a table with 2 fields. f1 and f2. i want when i press enter for the next record to copy the value of f1 to the value f2 of the new record
 
What's the point of having a table with duplicate records? Please tell us more about the background of this question so we can better assist you.
 
One rule of database normalization is to not store the same information multiple times. Can you explain exactly what it is you're trying to accomplish by duplicating the data?
 
ok. Here is the situation. in a table i have 2 fields in is a previous reading and the present one is the reading of a meter,
i want to press enter and on the new record to have automatic the present value of the record previous record to the present value of the new record.
for example. on the first record i have previous value 1200 and the present value 1400. When i press enter i want the value 1400 to show on the previous field
 

Attachments

These reading happed once every three months. i have a person who goes to the water reading meter and tell me that the new reading for the reader is lets say 1400. when i enter this value i calculate the amount of money the person have to pay according to his/her readings. Three monts later i get the new reading. So i want the value 1400 to go the next record automatic but to the place of the previous. i dont want to type it in again.
 
On my table i have more fields than the test i sent you. My only problem is that.
 
1707071382543.png

The classic way is NOT to redundantly store the previous value, but simply have a list of readings taken at certain locations on certain dates.
You can then use a query to calculate the delta between last time paid (not shown in my screenshot), and today.
 
Thank u. But i know how to do it with a query, i dont want to execute a query to do it. I want after i press enter to go to the new record automatic to get the above value to the new record. I also managed when i press the enter key to get the previous value of the old record to the previous of the new one. The broblem is how to get the present value of the previous record to the previous value of the new record.
 
ok. Here is the situation. in a table i have 2 fields in is a previous reading and the present one is the reading of a meter,
i want to press enter and on the new record to have automatic the present value of the record previous record to the present value of the new record.
for example. on the first record i have previous value 1200 and the present value 1400. When i press enter i want the value 1400 to show on the previous field
 
i want the value 600 to go to next one but on the place i had 450 before

450​
600​
600​
 
Simple query solution
SQL:
SELECT
   T1.ID,
   T2.XValue AS PrevXValue,
   T1.XValue
FROM
   test AS T1
      LEFT JOIN test AS T2
      ON T1.XValue = T2.XValue + 1
 
hI, i Am new here so i try to explain my problem. i have a table with 2 fields. f1 and f2. i want when i press enter for the next record to copy the value of f1 to the value f2 of the new record
Sorry, I didn't read your question completely. Nevertheless, I agree with the others that it is not necessary to record the previous value. After all, it is in the previous record and therefore you do not have to record it again. Make sure you have a field in your table that allows you to determine the order of the recorded values.
 
here is another possible solution, using Data Macro.
first I created a Query, TestQ that will sort your data by ID Descending.
next, I modify Test table and add Macro (After Update event).


you only need to Fill-up the Present Value field on your table and the previous will be written for you (after pressing enter key).
 

Attachments

Last edited:
I created a form so you can see my problem. Actually this form i sent is is a subform. so if you open the form test you gonna see three records. I want when i press the enter key on the last record the value of the present value to go to the previous value of the new record.
Dont buther about the code. As i said this is a part of a bigger program.

1707117510687.png
 
you need to enter some values to "present value" first.
then the "previous value" will appear.
 

Attachments

No. I am on the second record of my form. At the end of the record i press ENTER. i want that time (when i press the enter key the value of this record to appear on the value of the next record.
 
@alexsoft
For the move towards realism: Do you have exactly one meter and create a database for it?
With an Excel table, the learning curve would be a little lower - and almost everyone can do Excel.
 
I could go either way. With large enough volumes, it might actually make sense to store the previous meter reading on the current record rather than re-querying it every time. It's all about efficiency, and sometimes, it does make more sense to store the calculation rather than re-calculate it millions of times. It just depends on the situation, the scale/volume, and how many places that 'previous' needs to be recalculated.

If, out in the real world, no datamart or data architect ever stored calculated values, then you would be hardpressed to make a useable datamart out of any enterprise with millions or billions of records - and those dashboards would run awfully slow..

I'm on board with the rule, but not when we reflexively apply it with no exception, that's all.
 
@Isaac:
> reflexively apply it with no exception
I'm not doing that. If the OP was say writing software for an energy provider the size of Texas, they would have stated that, and Texas would not be so silly to run their billing system on Access, with a rookie developer.
This is more likely the scale of a couple of apartment complexes.
Once you go up several orders of magnitude, everything you know as a mainstream Access developer goes out the door.
 

Users who are viewing this thread

Back
Top Bottom