If current record field is same as previous, do n+1
Hi all,
I haven't been on here for AGES! Do apologise if I don't use the correct formats, but I'll try!
I should note that I am not good at VBA !
Basically, I need a way in Access of looking up the SumofCount of a previous record where the Selector is the same. Then, I need to take the difference away between them, as the site will have been paid for any previous recruits (SumofCount). If you know a better way of doing this, then I'm all ears but please, I'm not good at VBA at all, so you'd have to spoon feed me!
My logic of what is required is this:
1. Where Selector is the first instance for each particular number, I would like a new column with 0 for those lines.
2. Where Selector is the same as the previous record, I would like it to put a 1 in the first instance like this and then increment, e.g. 2, 3, 4 for the following 3 records. (The order of the query should be correct as it is sorted by 'Order').
3. Then, I would like to somehow (??) change the Previous CountofSum column so that it only looks up the previous SumOfCount where the Selector of the current records is the same as the previous record.
[Please see attachment as I cannot work out how to add a query view from Access]
I hope that makes sense?
Selector is made up of a study ID plus site ID.
Order is the same as Selector but also has year and month (e.g. 1212 or 1301, for 2012 December or 2013 January, respectively)
Many thanks, and oh, Happy New Year!
sparkes84
Hi all,
I haven't been on here for AGES! Do apologise if I don't use the correct formats, but I'll try!
I should note that I am not good at VBA !
Basically, I need a way in Access of looking up the SumofCount of a previous record where the Selector is the same. Then, I need to take the difference away between them, as the site will have been paid for any previous recruits (SumofCount). If you know a better way of doing this, then I'm all ears but please, I'm not good at VBA at all, so you'd have to spoon feed me!
My logic of what is required is this:
1. Where Selector is the first instance for each particular number, I would like a new column with 0 for those lines.
2. Where Selector is the same as the previous record, I would like it to put a 1 in the first instance like this and then increment, e.g. 2, 3, 4 for the following 3 records. (The order of the query should be correct as it is sorted by 'Order').
3. Then, I would like to somehow (??) change the Previous CountofSum column so that it only looks up the previous SumOfCount where the Selector of the current records is the same as the previous record.
[Please see attachment as I cannot work out how to add a query view from Access]
I hope that makes sense?
Selector is made up of a study ID plus site ID.
Order is the same as Selector but also has year and month (e.g. 1212 or 1301, for 2012 December or 2013 January, respectively)
Many thanks, and oh, Happy New Year!
sparkes84
Attachments
Last edited: