473,508 Members | 2,133 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Make last month's current data be this month's previous data

8 New Member
I need VB code that will automatically pull last month's current data and place it in this month's previous data.

We have a form that we use to document meter readings. So for example, when we take January's reading and place that in the field labeled "PresentValue" I would like December's reading to automatically load into the field labeled "PreviousValue". the form also contains the Meter's description as a field, as well as the month and year by which you are inputing the data.

Hope someone can help!
Jan 31 '13 #1
7 1892
zmbd
5,501 Recognized Expert Moderator Expert
To help we'd need to know a little more about the tables behind your data.

In a general sense, you need a query that will filter the records for the meter in question and then filter down again for the prior month's data - this can be done with one "WHERE" clause.
Jan 31 '13 #2
jpmatthews
8 New Member
I know how I can filter the data down to what I want in the query (the present value for one month prior) but I need to be able to insert that value into the form (into the previous value field).
Jan 31 '13 #3
zmbd
5,501 Recognized Expert Moderator Expert
In a general sense, you need a QUERY that will filter the records for the meter in
Notice I said "Query" above yes?
You need that query FIRST.
Once you have that query, you can use it in your controls or reports.

You have provided absolutly nothing about the design or the nature of your database and the dataset.

Please bear in mind the following:
- Out right requests for full code are against site policy.
Asking for someone to provide completed code or a completed project may result in the thread being delted.
- Bytes is not a code writing nor homework service. Please read the FAQ and posting guidlines before reposting your question.

-Please consult the FAQ and specific forum sticky threads for further information.
Jan 31 '13 #4
Rabbit
12,516 Recognized Expert Moderator MVP
Also, it sounds like your design is unnormalized. There really isn't a need for a previous value field in a table because each reading should have its own row and you would be repeating data by doing so.
Jan 31 '13 #5
zmbd
5,501 Recognized Expert Moderator Expert
You're absolutly correct Rabbit;
I had read OP post to mean that the value should/would appear in a "control" on the form/report and not as a field within the table.
Jan 31 '13 #6
jpmatthews
8 New Member
That's a good point about the repeated data. I never really thought about it that way.

I think I can get it to work now, I had just run into a wall and wasn't think it through correctly. Thanks!
Jan 31 '13 #7
NeoPa
32,557 Recognized Expert Moderator MVP
Please check out these links before posting any new questions :
How to ask "good" questions -- READ BEFORE SUBMITTING A QUESTION!.
Before Posting (VBA or SQL) Code.
Jan 31 '13 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

0
2444
by: Kate | last post by:
Hi... I have a foxpro program which is for producing excel reports back ended to foxpro table(.dbf). Since the table is getting bigger and bigger, it slows down my program. I need a program...
2
3637
by: Mary | last post by:
I am trying to develop a query which will determine the average costs using a rolling average of the past 12 months of data. In other words, if I entered the Ship Month of January and the Ship...
4
1853
by: Neil10365 | last post by:
I wonder if someone can help me with a small conundrum I am having. This is what I want to achieve: Scenario -------- Each week, I import an excel spreadsheet called Week1.xls into an access...
2
2486
by: Josef Meile | last post by:
Hi, I'm using a ComboBox, some Textboxes, and a DataGrid to represent a many-to-many relationship between Person and Course. Each time that I change the value in the ComboBox (which for now is...
1
19774
by: luna | last post by:
getting this error - i think its because im trying to put english date format into american date format (asp to sql server 2000) im getting the date using mortsourcedlabel.Text = Date.Today...
5
2342
by: libsfan01 | last post by:
Hi all Im trying to write a script that pulls data from another page (which is getting data from a db). The contents displayed on the db handling page (display.php) gets transferred through...
3
5224
by: STEPHENSS | last post by:
Hi, I have a crystal report that has many subreports over many pages and Iam getting the following error Unable to save data with report, the save data is incomplete generate the saved data Yes...
1
4604
by: craigfr | last post by:
I want to create a graph (automatically in a report) which compares the current year's values to the previous years by plotting two lines on one chart. I have one table which has the fields: ...
1
2299
by: guyborn | last post by:
I have been trying to get data from the database from the of the previous month to the second last week of the current month.I only managed to get data from the previous month to today's date. ...
3
3000
by: One | last post by:
Hi group - I want to do a SELECT based on a date range - but mySQL syntax expects the month range to be two digits. So I have converted the month to show the leading zero like this : ...
0
7225
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
1
7046
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5629
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4707
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3195
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3182
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1558
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
766
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
418
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.