Copy Info From Previous Record
Jul 20, 2005Suppose I have a customer database. Is there a way if I click on a button, it will create a new record and copy some of the info from the previous record?
View RepliesSuppose I have a customer database. Is there a way if I click on a button, it will create a new record and copy some of the info from the previous record?
View RepliesI have a table (tblStats). The user enters his current weight in a field named Wt. There are 2 other fields in the table named WkLoss and TTDLoss. These two fields are intended to be calculated. What I am trying to do is when the user enters his current weekly weight figure into the Wt field, I want the field WkLoss to get the user's weight from the previous record and place the difference in the field WkLoss. Also I would like to keep a total to date in the TTDLoss field.
So far this has been my attempt.
Code:Public Sub setWeight()Dim rs As DAO.RecordsetDim Startval As DoubleStartval = 190Set rs = CurrentDb.OpenRecordset("tblStats")'Select records to be updatedSet rs = CurrentDb.OpenRecordset _("SELECT * FROM tblStats ") rs.MoveFirst Do rs.Edit'field to update rs.Fields("WkLoss") = Startval rs.Update rs.MoveNext'increment step value Startval = WkLoss - Wt Loop Until rs.EOF rs.Close Set rs = Nothing End Sub
All I get is the value 190 placed in the first record and all zeros in the subsequent records. Also I don't have a clue as to how to get the Total To Date field to calculate.
Any help would be appreciated
Thanks for your time.
Hi
I need to copy some data from last record to next(New record), when a user clicks a button on a form. I don't want to copy all the data.
An example would be booking in items from an invoice:
Company would be the same
Invoice number would be the same
Product code would be different
quantity would be different
Hope this makes some sence, and i'm not being stupid:rolleyes:
Andy
I found and pasted some code which copies records from the previous record on the form. Seems to work well, but I was wondering if there is an issue with the copying of the first field which is a combo box?
View 10 Replies View RelatedIt is a continuous subform (Names: Form = ClientUpdate / Subform = ClientUpdateSub.
All of the data implicated here is direct and in the subform's query table including the button we want to program.
(This is my example but it wont stay in columns in this "post box" )
IDNo App _ID App_Freq App_Date GetDates Action_Date
22 18 56 21-Jun-13 BUTTON 14-Jun-13
21 19 56 16-Aug-13 BUTTON 9-Aug-13
*
The GetDates Command BUTTON should generate the red data above, like:
Private Sub GetDates_Click()
Go to a new record
Go to the field App_Freq and fill it with:
Copy/paste the data from the field of the same name in the previous record
Go to the field App_Date and fill it with:
data based on this calculation using the PREVIOUS record fields: App_Date + App_Freq (which are days)
Go to the field Action_Date and fill it with:
data based on this calculation: App_Date (of current record now filled out - step above), minus 7 (days).
End Sub
That's it!
All the dates format is set to medium date. An error message should come up in case App_Freq is empty, for example
Also note that the data can be manually changed at any time and should not revert to its last calculation. The button only generate data into a new record.
I have an access form that needs filling in daily by various people.
It's to document changes to a website and I currently have a combobox box set up for the various sections to state whether they are AMENDS, REVERTS or NO CHANGE.
I have set conditional formatting to then highlight these sections but am also trying to get it to work so that if the user chooses "NO CHANGE" then the data for that field copies over from the previous record.
I have set this up in the AfterUpdate code for the combobox, but nothing is happening, not even an error....
Code:
Private Sub COMBOBOX1_AfterUpdate()
If Me.COMBOBOX1 = 3 Then
Me.[FIELD_TO_CHANGE] = DLookup("[FIELD_TO_CHANGE]", "tb_TABLE", "[ID]=Forms![form_FORM]![ID]-1")
End If
End Sub
(Where 3 is the value of NO CHANGE in the combobox, and FIELD_TO_CHANGE, tb_TABLE and form_FORM being the names of the various elements)...
I am tasked with creating a scientific database of fish catches at various different sampling stations. I envisage the entry form having hierarchy levels, ie year, season, date, sample station, species caught, and then the specific associated data with each species (weight, abundance, length etc) will form each distinct record.
In each year there are 2 sampling seasons. In each sampling season there are up to 20 dates on which samples are taken. On each date there are up to 50 sample stations recorded. And at each station up to 20 species can be recorded.
In order to enter each species caught in a survey, the end user will potentially have to fill the season box with an entry 40,000 times. For each season there will be 20,000 date entries to be made. For each date, 1,000 station code entries, and 20 species entries for each station. What I would like to happen is this.
When the end user is entering the data, he or she will be working through the hierarchy from the ground up. Ie., they will enter a particular species' data (abundance, weight, length etc) at a particular station on a particular date during a particular sampling season. The next entry will be a different species at the same station on the same date during the same season. I would like the duplicated information from the previous record to be copied across onto the new one so that all the end user has to do is enter the species name, abundance weight and length data.
Once they have finished entering all the species data for that particular site, they can move onto the next site which they would fill in the data themselves for the station code. So, in the hierarchy, the first button would copy all the previous data except the species name and associated weight length abundance data. The next button would do the same, except leave the station code blank. The next button would leave the species name, station code and date blank. And so on up the hierarchy. The end user would be able to selectively choose which data is copied over by using these buttons, saving lots of potential extra work doing repetitive entries.
I have 2 different sets of tables,forms and queries, one for quotes and the other for orders.
All is basically simalar but the reason why i did not combine the two in one set of tables and queries is because after a certain time i want to delete some quotes and would also have too many fields in one table to manage.
Both have a main form (own table)with customer detail and then the subform (own table) contains various fields with data relating to products.
My problem now is because one in 5 quotes get accepted i want to just copy one field from main quote form to main order form and then 6 fields from quote sub form to order sub form, the rest of the info will have to be put in manaully in the orders form and sub form.
I thought of running a macro to open order form but not sure how to populate the relative fields.
Any suggestions, prob simple way of solving this but i am self taught and therefore dont know it all.
I have a form that I need to turn into a table. The table will be updated each day with new information but I dont know what to do to keep the previous days info. I have attached the form ....
View 3 Replies View RelatedI have a [New Job Number] form in my database. In this [New Job Number] form, I have a [Purchase Orders] subform showing all open Purchase Orders. I have a button in the [New Job Number] form to open another form called [New Purchase Order]. How can I transfer all of that information from [New Job Number] into the [New Purchase Order] form through a macro? I don't know how to use VBA. Also I do know how to use basic Macros, though.
The fields I would like to transfer from [New Job Number] into [New Purchase Order] are JobName, JobNumber, and CustomerAccountNumber.
I am wondering if Access 2010 has the capability of automatically filling in a field from info keyed into previous fields. For example, I want a confirmation number issued which is made up of all the characters keyed in the previous three fields. For example, assume the previous three fields are:
Block = 01
Building = 125
Room = A
Confirmation Number =
Therefore, the confirmation number would automatically be filled in as 01125A.
If so, how do I go about setting it up?
What's the best way in an update query, using access 2003, to update data in a record based on the previous record having an identical value in a certain field?
For example my data looks something like this, in this example I want row 2 to fill in the blanks with the data from row 1 as they both have the same ID number at the end highlighted in red:
1 2 Anywhere Street 1 2 1 1 5423
2 4 Anywhere Street . . . . 5423
3 6 Anywhere Street 1 2 1 1 6401
4 8 Anywhere Street 1 2 1 1 6402
I've found various threads here on how to copy the whole record but I only want to copy the data from certain fields. More oftem than not the fields I'll be copying to will be NULL.
how to reference a field from the previous record within an update query I could probably work it out from there?
Hi,
Does anyone know how to exclude the header information when copying a record from an Access table and pasting it into Excel. When I paste into Excel, it is also pasting the header information from Access which I do not want. I only want the data to be pasted.
Thanks for the help in advance.
BJS
I have spent the day using Access 2010 and attempting to move information from a parameterized query into specific cells in an excel template. It runs smoothly until I attempt to reference the query at which point I run into th error "Too few parameters. Expected 1." Currently my reference code looks like this:
Dim T As Recordset
Set T = CurrentDb.OpenRecordset("SELECT [8D Data].ID, [8D Data].[Customer Closed], [8D Data].[Days Open], " & _
"[8D Data].[Open Date] , [8D Data].[QN #], [8D Data].[Last Report Date], " & _
"Leaders.[Leader Name] , Leaders.[Leader Title], Leaders.[Leader Phone #], " & _
"Leaders.[Leader Email], [8D Data].[Part Description], [8D Data].[Customer P/N], " & _
"[8D Data].Customer , [8D Data].[Vehicle Year], [8D Data].[Problem Description]" & _
"FROM [8D Data] INNER JOIN Leaders ON ([8D Data].Lead = Leaders.ID)" & _
"WHERE ((([8D Data].ID)=[Enter QCR #]));")
I need a way to dynamically store a particular value in "field_2" of the CURRENT record depending on whether or not the value of "field_1" of the CURRENT record is identical to the value of "field_1" of the PREVIOUS record within the same table. The table is sorted on "field_1".
So, if the value of "field_1" in the CURRENT record is "ABC" and the value of "field_1" in the PREVIOUS record is also "ABC", then store a value of "PPP" in "field_2" of the current record. IF on the other hand, the value of "field_1" in the CURRENT record is "ABC" and the value of "field_1" in the PREVIOUS record is "XYZ", then store a value of "WWW" in "field_2" of the current record.
I have a report that will use these results to count only the number of records that have a "WWW" in "field_2".
Is this doable, maybe in a query somehow?
I should add that whatever the solution, it needs to be compatible with Access 2000.
How to fill values in a new record with data from previous record?
I've total 11 columns in a table and values in 3 4 columns are repeating for few rows before it needs to be changed eventually. I want to fill these rows with values from previous record.
I need to know how to auto enter the date of the previous record into a new record. I have this db for my vehicle log sheets and I submit monthly a claim for the business km from my company. I usually cant remember the date of the previous claim and have to scroll back until I find the field with a date. It will be useful if the date was copied into every new record until I edit the date when I submit the claim. What I ask is during the new month all the dates will be the same until I submit the claim. I do not know how to do this, and yes I have done a search.
View 3 Replies View RelatedI'm struggling with a query to evaluate current and prior record data. I have a query producing 5000 records. I need to group records by Case ID and compare current date record to previous date record to determine if a team and worker name has changed during the year. I need to count how many times a cases is transferred to and out of a particular team from the beggining of the year. i.e., On 1/1/2014-Team1 has an inventory of 500 cases.
During the month 25 cases are transferred into Team1 and 15 cases are transferred out of Team1. So on 2/1/2014 Team1 begins with an inventory of 510 cases. Throughout the year cases come and go from and to Team1 each month so need to figure out how to create a query to count each change. See attachment displaying how the data is listed and how I invision it to work with the In/out column counts.
Specifically, at the begginig of the year (1/1/14) for case ID 1003 you can see it belongs to Mary in Team1 for January and February. Then in March the case is transferred out and went to Joe in Team 3. So for Mary a "-1" is recorded as a negative count for that Case ID. If later in the year the case is transferred back to Mary a "+1" would be recorded. Respectively evaluated for each of the 5000 records to get a total count for each of the teams by Case ID throughout the year.
I've started with DLookup, tried comparing current month to previous month using DMax. It works as long as I only select one case ID used in a separate query but if I use the whole subset (5000 records) it fails. I can't figure out how to group each set of case IDs and then apply the query.
My attempted query: DLookUp("[Team]","[Team_qry]","[Team_qry]![Date]=#" & CStr(DMax("[Date]","[Team_qry]","[Team_qry]![Date] <#" & CStr([Date]) & "#")) & "#")
create a macro that automatically fills in the next invoice number in sequence",,I'm assuming this macro would look at the value of the previous record and add a one to itI don't want to use a AutoNumber field as I might need
(a) to modify value or
(b) need to skip numbers.
In my query, i want to automatically display the value of another field from the previous record in a field in my current record. i.e.
Name Value Previous
Record 1 1
Record 2 2 1
Record 3 7 2
Record 4 1 7
Is it possible to create some kind of simple expression to refer to data in another record?
Cheers,
Ben
Hi there,
Can someone help me on this issue?
I want to copy Postal Address Information to Visit Address Information wthin the same record, in my Contact Database that I am building at the moment.
I want to copy 4 fields to 4 other fields within the same Record.
This the current code I use for the Copy-button:
---
Private Sub cmdCopyFields_Click()
Dim v1 As Variant
Dim v2 As Variant
Dim v3 As Variant
Dim v4 As Variant
v1 = Me!Field_a.Value
v2 = Me!Field_b.Value
v3 = Me!Field_c.Value
v4 = Me!Field_d.Value
RunCommand acCmdRecordsGoToNew
Me!Field_e = v1
Me!Field_f = v2
Me!Field_g = v3
Me!Field_h = v4
End Sub
---
The underlined part (acCmdRecordsGoToNew) is false part of this code, because it copies the Adress Info to a new record, instead of copying it in the same.
-Is there someone that can help me with this problem, to make the copy-button in the Form run properly?
-Are there other options to achieve te same?
I have put in a attachment, to give you guys a visual example of what I mean.
Thanks in advance,
Quinten
I need to add two previous record fields together in a query. I have attached a picture to illustrate.
The "StudyYears" filed is the primary key of the table the data is being pulled from. The zero's are placeholders for the sum of the previous record's data.
RunningBalance is calculated as follows:
Code:
RunningBalance: IIf([a].[StudyYears]=[ReserveParameters]![StartingBalanceYear],CCur([ReserveParameters]![StartingBalance]),0)
Bal is calculated as follows:
Code:
Bal: [AnnualContribution]+[InterestIncome]+[Inflation_Adjusted_Expenditures]
How to go about adding the two together as in the picture?
Is there a way to do this relatively fast, as well as keeping the query updateable?
How do you compare one record to the previous record? I have a query that shows items sold. It is sorted by day with today on top. I would like to create a column that has a 'thumb up' or 'thumb down" if todays was a better day than yesterday.
View 1 Replies View RelatedI have a table for Contact history.
All data ca vary except for two fields The ID wich will be multiples of and the election date.
I want to display the last contact info we have how can I do this.
I am running A Form.
I have created it that I if I Double Click on one of the fields, it automatically creates a copy (which is run from a Query).
That all works fine.
My problem is that my Table has 500 Records and I want the Form to jump straight to the New Record after it creates it.
Here is my Code:
Code:Private Sub USName_DblClick(Cancel As Integer) DoCmd.OpenQuery "Copy_Drug" Me.RequeryEnd Sub
I have the employee data record... I want copy of the same record to insert in table but with different employee id and Site through forms. StaffNo is the primary key.
For example
existing record
StaffNo, Site, Name, hiring date, etc
AKA-111, 10, John, 25-10-13
new record
StaffNo, Site, Name, hiring date, etc
ALM-123, 14, John, 25-10-13