My table (shown below) only has 3 columns, although I've manually added the other 3 for illustration purposes in case I wasn't making myself clear.
Expand|Select|Wrap|Line Numbers
- ID HitDate HitTime VisitorPageNo VisitNo VisitPageNo
- 10004-055052 03/02/2007 17:50:52 1 1 1
- 10011-172249 03/02/2007 17:22:48 1 1 1
- 10011-172249 03/02/2007 17:23:02 2 1 2
- 10011-172249 03/02/2007 19:23:28 3 2 1
- 10011-172249 03/02/2007 19:24:21 4 2 2
- 10019-093023 03/02/2007 09:30:23 1 1 1
- 10023-215744 03/02/2007 21:57:44 1 1 1
- 10023-215744 03/02/2007 21:57:49 2 1 2
- 10023-215744 03/02/2007 21:58:30 3 1 3
- 10033-202533 03/02/2007 19:25:32 1 1 1
- 10033-202533 03/02/2007 20:25:45 2 2 1
- 10033-202533 03/02/2007 20:26:00 3 2 2
- 10033-202533 03/02/2007 21:26:09 4 3 1
- 10033-202533 03/02/2007 22:31:40 5 4 1
I'm sure the same result could be achieved in a simpler and more efficient way using VB. I have experience of Basic and other programming languages, but I'm a novice at VB. I've searched on recordsets and so on, but have not been able to find something similar I can adapt.
I've attempted to write some logical instructions that should solve the problem. I don't know if this is of any help!
Expand|Select|Wrap|Line Numbers
- dim x as integer
- dim VisitPageNo, VisitNo, VisitPageNo, TimeOnPage as recordset
- x = 1
- VisitorPageNo(x) = 1
- VisitNo(x) = 1
- VisitPageNo(x) = 1
- While not EOF
- x = x+1
- If ID(x) = ID(x-1) then
- If HitDate&HitTime(x) < HitDate&HitTime(x-1) + 1 hour then
- TimeOnPage(x-1) = HitDate&HitTime(x) - HitDate&HitTime(x-1)
- VisitorPageNo(x) = VisitorPageNo(x-1) + 1
- VisitNo(x) = VisitNo(x-1)
- VisitPageNo(x) = VisitPageNo(x-1) + 1
- Else
- VisitorPageNo(x) = VisitorPageNo(x-1) + 1
- VisitNo(x) = VisitNo(x-1) + 1
- VisitPageNo(x) = 1
- End
- Else
- VisitorPageNo(x) = 1
- VisitNo(x) = 1
- VisitPageNo(x) = 1
- End if
- Wend
Thanks