Queries :: Evaluating Current Record To Previous Record To Get Counts

Aug 8, 2014

I'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]) & "#")) & "#")

View Replies


ADVERTISEMENT

Queries :: Datediff From Previous To Current Record

Oct 10, 2013

I want to get the datediff of the last returned date from vacation and the current vacation start date. But how to get difference from the previous record's date to this current record's date. I want to show date difference in an unbound textbox. I have a contiuous form which shows all vacation list of employees. It shows how many times he went vacations and when he went and when he returned.

View 14 Replies View Related

Dynamically Update Field Of A Current Record Based On Previous Record

Apr 30, 2007

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.

View 1 Replies View Related

Refer To Previous Record In Current Record Query

Sep 15, 2005

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

View 6 Replies View Related

Compare Current To Previous Record In Query

Aug 14, 2007

I have a table of customers who report trouble on their equipment. I would like to compare the date in the current record to the previous record to see if it occurred within 30 days. Can I do this with an SQL query or expression?

View 2 Replies View Related

Conditional Format Based On Previous And Current Record

Feb 4, 2005

I'm having trouble with a tricky conditional format in a continuous subform.

The criteria is based on field [GroupNo] when it changes (increases) which are always listed in numerical order.

Basically all I want to is for the text box colour to alterante (eg blue & yellow)when GroupNo changes value

So it would look something like this....

Group NoID (highlight colour)

1 (yellow)
1 (yellow)
1 (yellow)
2 (blue)
2 (blue)
2 (blue)
3 (yellow)
3 (yellow)
etc etc

btw, although values will always be in order they may not all be output, so it's not just case of odd, even, odd, even (that would be too easy!)

I can retrieve the Previous Record's GroupNo value (via a function) in another text box and compare current GroupNoID with this in the Format Expressions and manage to change the colour, but it won't sustain this new colour for the subsequent same GroupNos, obviously as the values have changed.

So how can I....

Change the colour when the value changes.
Keep this new colour until it the value changes (increases) again.

Many Thanks

View 14 Replies View Related

Forms :: Return To Previous Current Record After Requery

Jul 30, 2013

I have a Main form that has button that loads a new Pop Up form for entering new data that will display in the Main form. When all the data is entered I click on a button that Saves the data and exits the form and then runs Re-query on the main form returning to the record that was current before the requery.

I have the following code:

Private Sub cmdSaveTradeAndExit_Click()
DoCmd.RunCommand acCmdSaveRecord 'Save the current record
DoCmd.Close 'Close the current form
Dim CrId As Integer
CrId = Forms!frmTransactionMainActivePopUp.CurrentRecord
Forms!frmTransactionMainActivePopUp.Requery
DoCmd.GoToRecord , Forms!frmTransactionMainActivePopUp, acGoTo, CrId
End Sub

But I am getting the following error:

Run-time error '2498':

An expression you entered is the wrong data type for one of the arguments

And the following is in yellow in the debug:

Code:
DoCmd.GoToRecord , Forms!frmTransactionMainActivePopUp, acGoTo, CrId

View 4 Replies View Related

Modules & VBA :: Subtracting Value On Current Record From The Value Of Previous Records?

Jun 5, 2013

I want subtrack a value on the current record from the previous record and display the result in text box in subform datasheet. This is done during data entry. The calculation works most of the time and randomly it returns the wrong value. I have the code in an after update event after I enter a number. Here is what my code looks like:

sysHopSpacing = Abs([sysHop1] - DLookup("[sysHop1]", "tblSystemConfiguration", "[sysBaseNumber]=Forms![frmTempestCoordination]![frmSubSystem]![sysBaseNumber] - 1 "))

This is how I generate the sysBaseNumber

sysBaseNumber = Nz(DMax("sysBaseNumber", "tblSystemConfiguration", "sysAccountID=" & Forms!frmTempestCoordination!accAccountID), 0) + 1

I am using DMax so I can keep the subform records with the parent form record.

My results are inconsistant:

This is what I want the subform to do when subtracking from the previous record

syshop1 sysHopSpacing
5
20 15
30 10

Instead I get a result that does not make sense like this:

sysHop1 sysHopSpacing
5
20 15
30 4

I cant trace it down.

View 14 Replies View Related

Queries :: Add Previous Record Data To Next Record

Apr 11, 2013

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?

View 1 Replies View Related

Queries :: How To Compare One Record To Previous Record

Feb 20, 2014

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 Related

Queries :: Can A Calculated Field Look At Record Before Current Record

May 1, 2013

I have a query to bring in values, I need to select 2 rows of data but the criteria is as such:

x= starting value on form

now the row of data must match the following criteria previous row to current row(ref temp)<=x And Current row(ref temp)>xnext row to current row(ref temp)>=x And Current row(ref temp)<x

I have dealt with SQL before but how to do the above.The isolated 2 rows of data will then go into unbound boxes on a form from which I will do intercept and gradient calculations.

View 5 Replies View Related

Queries :: DLOOKUP To Look At Value For Previous Record

Sep 23, 2013

I have a table that will have ITEMID as unique field but location could have save values. I tried using DLOOKUP to look at the value for the previous record to see if I need that value is same as current, however, since my data query are text formats, I am unable to. I get a message of mismatch data type. apply my query to look at sorted table by Location and ITEMID and if previous location = location, then my area=0?

View 6 Replies View Related

Queries :: Lookup At The Previous Record In The Table

Jan 25, 2014

I've got stuck in preparation of this sales query. The primary sales table contains a mix of Canadian and the US detail invoice sales records. All sales records are in their native currencies The secondary lookup table contains daily US/CAN foreign exchange rates (FX).

I need to multiply every $US sales record (marked with U) with the FX rate in order to convert it to the Canadian currency. Unfortunately, this FX lookup table is missing over 50 daily rates in the last two years and as a result I cannot match them date-by-date with the sales table.

As a workaround, it is acceptable to use the previous FX rate in the table. The previous rate can be one or more days before the transaction occurred.

Attached is a sample database with the query that I've already built. The query contains two sample US records that are missing the FX rate on Jan 6. The FX rate of $1.0639 that needs to be applied to it should come from Jan 3rd entry.

New Datesales matcode curtype trans newrate
1/3/20141225.61281173224U R187611.0639
1/3/2014344.70361173260U R181731.0639
1/6/20142520 0022691U R19841
1/6/20145400 0022692U R19841

View 14 Replies View Related

Queries :: Calculations With Values In Previous Record(s)

Jan 12, 2015

I have a database where I need to record student data, specifically marks and absenteeism. The marks are recorded each term as a running total. I have a final mark which needs to be equal to the 4th term mark.

I also need to record the number of days absent each term with a total at the end of the year.

My problem is that the term 4 mark is a in the previous record and the total days absent needs to be the total of the previous 4 records (term 1 - 4).

I using a create table query and an update query but that was a no go.

View 7 Replies View Related

Queries :: Find Previous Record In A Query?

Jun 13, 2015

How do I find the previous record in a query using the autonumber field?

View 10 Replies View Related

Queries :: Query To Pull Previous Record

Jan 20, 2014

I have a form that is used to book a new event for a client who is already in the database.Within that form I have a subform that is based on a query which displays information from that client's previous event. I did this using a solution found in the following thread: URL...It is based on pulling the second to last record that is related to the current client. It works perfectly when booking a new event that has taken place on a previous date. However, if the previous event occured on that same date (but at a previous time), it doesn't register.

I would prefer a query that would pull the record previous to the current one, instead of pulling the second to last record out of all that client's events.it would also mean that if more events are booked, then a past event is opened in a form, the sub forms in that form will display the event just prior to the current record.

View 14 Replies View Related

Queries :: Refer To Previous Record In A Query

Mar 29, 2015

I'm trying to refer to previous record in a query and i'm stuck as i do not know how to do it.

Here is my query:

Code:
SELECT
[Prod2Buy].[Product Code],
IIF([Missing] IS NULL,0,[Prod2Buy].[Quantity To Order]-[To Order]) AS [Rest To Order],
s.s_manu_code AS [Manufacturer Code],
s.prod_cost AS [Price Code],

[Code] ....

In fact the line: IIF([Missing] IS NULL,0,[Prod2Buy].[Quantity To Order]-[To Order]) AS [Rest To Order] should refer to previous record.

View 9 Replies View Related

Queries :: If 0 From Subtract In Query Then Goto To Previous Record

Oct 5, 2014

I want substract from 9/20/2014 totreg40 - reg = ovt but when reg=0 the remainder subtract from 9/19/2014 (previous record) totreg40 - reg = ovt, etc. The sum of reg = 40.

IDFECHA REGOVTTOTREG40
2309/15/2014 5.5 0 46.75
2319/16/2014 8 0 46.75
2329/17/2014 8 0 46.75
2349/18/2014 7.75 0 46.75
2979/19/2014 8 0 46.75
2359/19/2014 8 0 46.75
2339/20/2014 1.5 0 46.75

I want the result like this:

IDFECHA REG OVT TOTREG40
2309/15/2014 5.5 0 46.75
2319/16/2014 8 0 46.75
2329/17/2014 8 0 46.75
2349/18/2014 7.75 0 46.75
2979/19/2014 8 0 46.75
2359/19/2014 2.75 5.25 46.75
2339/20/2014 0 1.5 46.75

View 1 Replies View Related

Queries :: Finding Previous Record Date Difference?

Dec 17, 2013

I am trying to use a query to find the previous record of a transaction and provide an additional field that computes the difference in the dates in days. (The days from TransferID 23 to TransferID 24)

TransferID Job Number Tool Number TranferDate DaysOnRent
22 1 10 9/1/13
22 1 12 9/1/13
23 2 10 10/18/13
23 2 12 10/18/13
24 3 10 12/15/13
24 3 12 12/15/13

I have seen other posts that reference the following link.

[URL]

View 8 Replies View Related

Variables And Record Counts

Feb 6, 2008

I have a telephone database with call detail records for every call. In my criteria selection, I am selecting only inbound (CallType 2), and (outbound CallType 3) call records. I need to count the total number of records in each CallType. I have very little experience using a gui type database management software like Access, (I use to use DB2 on an AS400). I am trying to create a variable like you would in VB and use it in Access put can't figure out how to do that.

Little background on the database project: In our customer service center, I need a report that displays the total number calls for each customer service rep, inbound, and outbound calls, for a specific date range. CallType 1 = intercompany calls (which I want to exclude), CallType 2=inbound CallType 3= outbound.

View 1 Replies View Related

Tables :: Auto Fill Values In New Record With Data From Previous Record

Apr 29, 2015

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.

View 10 Replies View Related

Forms :: How To Auto Enter Date Of Previous Record Into New Record

Aug 26, 2013

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 Related

Auto Increment A Number Based On Record Value From Previous Record

Nov 17, 2010

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.

View 8 Replies View Related

Queries :: How To Create Auto-grouping Based On Change In Previous Record

Jun 29, 2015

I have a column "CAT" each time that CAT switches between 0 and 1, I would like my query to auto-create a "grouping" and increment the group by 1. What I am looking for is the output as shown below.

ID CAT GROUP
67 0 1
68 0 1
69 0 1
70 1 2
71 1 2
72 0 3
73 0 3
74 0 3
75 0 3
76 1 4
77 1 4

View 6 Replies View Related

Queries :: How To Keep Only The Most Current Date Record In Table

Mar 8, 2014

I have this table that records sales events for properties, with multiple sales records for some parcels. Each parcel has unique field: MapTaxlot. I want to create a select query or make table query that shows only the most recent sale event for each parcel. Instrument_Date is the date field for the sales records.

See attached example of the data table below.

What is the simplest method to accomplish this?

TableSnip.JPG

View 5 Replies View Related

Queries :: Append Just Current Record Into A Table

Jul 17, 2014

I am trying to open a form with some records taken from one table, then alter couple of data in it and after that most importantly to append current records into a different table. The reason I need to append is that I need to keep track on every occurrence on same fields.

It looks like this:

SerialNumber(Field 1), ServiceDate(Field 2), ServiceEngineer(Field 3)

Now suppose same serial number called again and asked for service, I need to still keep record on how many times this same serial number had service.

View 9 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved