473,569 Members | 2,872 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 "PresentVal ue" 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 1897
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,564 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
2454
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 which can create a table archive to store last month's data which isn't needed for this month's report. Therefore, I can run that archive program once...
2
3642
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 Year of 2004, I would want that month plus the preceding 11 months of data to determine an average cost. How can that criteria be entered in a query...
4
1860
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 database. This table is then called Week1Data. Already in the database is the table from the previous weeks import, which is compared to the latest...
2
2491
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 the OID of Person), the information of the person matching the selected OID is shown in the Textboxes (Name, Address, id, etc) and the courses this...
1
19777
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 mortsourcedlabel.Visible = True mortsourced.Visible = False which throws the date out (in uk format) to 13/02/2004 - all well and good
5
2345
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 XMLHttpRequest continuously, however when setting the value using getElementById the value of the element is not being replaced, it is being appended...
3
5231
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 or no. If i go to the last page and try save data I get no error message. Need Help
1
4608
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: Date and DeckDefects (which is a number) I would like the X axis to show months and the Y axis to show # of DeckDefects
1
2307
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. your help will be highly appreciated Regards Guyborn
3
3007
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 : $next_month = date('m')+1; $this_month = date('m'); $pre_month = date('m')-1;
0
7703
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7619
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7983
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5514
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5228
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2118
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 we have to send another system
1
1229
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
950
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.