PC Review


Reply
Thread Tools Rate Thread

how do i count each record based on date

 
 
=?Utf-8?B?TWlrZVN3ZWV0?=
Guest
Posts: n/a
 
      13th Oct 2006
I need to have a number automatically created utilizing each record added to
the year. I have it working now (based off the current reord plus the last
two of the year) but the problem is I need it to start over at the end of
each year. It should not be this difficult but I am stumped! We need to keep
track of how many requests we have for each year. A user enters the data
(could be many times an hour) then this is stored in the table. I am using
ACCESS 2003.
 
Reply With Quote
 
 
 
 
Jeff Boyce
Guest
Posts: n/a
 
      13th Oct 2006
Mike

It sounds like you want to use a number to "count", and to set up a field in
a table, and ....

How about just using a query to count the annual number of requests where
Year(YourDateField) = 2006? (or whatever)

Regards

Jeff Boyce
Microsoft Office/Access MVP

"MikeSweet" <(E-Mail Removed)> wrote in message
news7EB5458-B8FC-44AE-8AE4-(E-Mail Removed)...
>I need to have a number automatically created utilizing each record added
>to
> the year. I have it working now (based off the current reord plus the last
> two of the year) but the problem is I need it to start over at the end of
> each year. It should not be this difficult but I am stumped! We need to
> keep
> track of how many requests we have for each year. A user enters the data
> (could be many times an hour) then this is stored in the table. I am using
> ACCESS 2003.



 
Reply With Quote
 
=?Utf-8?B?TWlrZVN3ZWV0?=
Guest
Posts: n/a
 
      13th Oct 2006
Thanks for the quick response.
Yeah...I thought of that but I need it to be dynamic. Here is what I have:
1.) A request comes in from the field for work to be done
2.) Engineer receives the order and if they approve then a number is
assigned to that request
3.) When they put in the date that the request is approved I take the last
two numbers of the year adding it to the record number
4.) This is what we call an ERS number
5.) Right now my number looks like this: 1.2006, 2.2006, 3.2006
6.) That number has to increment up to the end of each year starting over
with one (i.e. 1.2005, 1.2006, 2.2006)
7.) If the engineer doesn't approve it then it doesn't get a number but is
still stored in the database table

If I can have a number automatically be entered into a field when the
request has been approved (APPROVED_NUMBER) and then attach it to the year
but reset it to one when the year changes that would be good. I even thought
of basing it on an hour/minute/day along with the year. I thought of the hour
but more than one may be entered during that time.
I'm stumped....
Maybe it will come to me this weekend when I'm not thinking of it.

"Jeff Boyce" wrote:

> Mike
>
> It sounds like you want to use a number to "count", and to set up a field in
> a table, and ....
>
> How about just using a query to count the annual number of requests where
> Year(YourDateField) = 2006? (or whatever)
>
> Regards
>
> Jeff Boyce
> Microsoft Office/Access MVP
>
> "MikeSweet" <(E-Mail Removed)> wrote in message
> news7EB5458-B8FC-44AE-8AE4-(E-Mail Removed)...
> >I need to have a number automatically created utilizing each record added
> >to
> > the year. I have it working now (based off the current reord plus the last
> > two of the year) but the problem is I need it to start over at the end of
> > each year. It should not be this difficult but I am stumped! We need to
> > keep
> > track of how many requests we have for each year. A user enters the data
> > (could be many times an hour) then this is stored in the table. I am using
> > ACCESS 2003.

>
>
>

 
Reply With Quote
 
Jeff Boyce
Guest
Posts: n/a
 
      14th Oct 2006
By definition, a query IS dynamic.

Regards

Jeff Boyce
Microsoft Office/Access MVP


"MikeSweet" <(E-Mail Removed)> wrote in message
news:CA8FF59F-69E2-4E47-8E33-(E-Mail Removed)...
> Thanks for the quick response.
> Yeah...I thought of that but I need it to be dynamic. Here is what I have:
> 1.) A request comes in from the field for work to be done
> 2.) Engineer receives the order and if they approve then a number is
> assigned to that request
> 3.) When they put in the date that the request is approved I take the last
> two numbers of the year adding it to the record number
> 4.) This is what we call an ERS number
> 5.) Right now my number looks like this: 1.2006, 2.2006, 3.2006
> 6.) That number has to increment up to the end of each year starting over
> with one (i.e. 1.2005, 1.2006, 2.2006)
> 7.) If the engineer doesn't approve it then it doesn't get a number but is
> still stored in the database table
>
> If I can have a number automatically be entered into a field when the
> request has been approved (APPROVED_NUMBER) and then attach it to the year
> but reset it to one when the year changes that would be good. I even
> thought
> of basing it on an hour/minute/day along with the year. I thought of the
> hour
> but more than one may be entered during that time.
> I'm stumped....
> Maybe it will come to me this weekend when I'm not thinking of it.
>
> "Jeff Boyce" wrote:
>
>> Mike
>>
>> It sounds like you want to use a number to "count", and to set up a field
>> in
>> a table, and ....
>>
>> How about just using a query to count the annual number of requests where
>> Year(YourDateField) = 2006? (or whatever)
>>
>> Regards
>>
>> Jeff Boyce
>> Microsoft Office/Access MVP
>>
>> "MikeSweet" <(E-Mail Removed)> wrote in message
>> news7EB5458-B8FC-44AE-8AE4-(E-Mail Removed)...
>> >I need to have a number automatically created utilizing each record
>> >added
>> >to
>> > the year. I have it working now (based off the current reord plus the
>> > last
>> > two of the year) but the problem is I need it to start over at the end
>> > of
>> > each year. It should not be this difficult but I am stumped! We need to
>> > keep
>> > track of how many requests we have for each year. A user enters the
>> > data
>> > (could be many times an hour) then this is stored in the table. I am
>> > using
>> > ACCESS 2003.

>>
>>
>>



 
Reply With Quote
 
j_beverly
Guest
Posts: n/a
 
      15th Oct 2006
Mike,

I am an amateur, so this may or may not be the best way, but I was
intrigued by your question and here is what I came up with:

I would create a table to store the next approval number. The table
would have 2 fields: a sequence number and the year.
TableApprovalNumber
Field Name: Sequence Data Type: Number
Field Name: Year Data Type: Number

The table would always have only one record which will have the next
approval number to be assigned to an approved request.

On a form for entering/updating requests, I would have a command
button or checkbox called "Approved".
Cllicking on "Approved" would first compare the current year with the
year in TableApprovalNumber. If the current year is greater, then
TableApprovalNumber.Year is set to current year and Sequence is reset
to 1.

Then I concatenate the Sequence and Year to form the Approval Number.
Lastly, the Sequence is incremented so is ready for the next request
approval. Here is my code:

Private Sub Approved_AfterUpdate()
If Approved Then

Dim y As Integer 'year
Dim s As Integer 'sequence
Dim thisyear As Integer


y = DFirst("[Year]", "TableApprovalNumber")
thisyear = Format(Date, "yyyy")

'If this is the first number of a new year, reset the sequence to 1
If thisyear > y Then
DoCmd.SetWarnings (False)
DoCmd.RunSQL ("UPDATE TableApprovalNumber SET
TableApprovalNumber.Sequence = 1, TableApprovalNumber.[Year] = " &
thisyear & ";")
DoCmd.SetWarnings (True)
y = thisyear
End If

'Get approval number for this project
s = DFirst("[Sequence]", "TableApprovalNumber")
'Concatenate Sequence & Year to form Aproval Number
ApprovalNumber = Str(s) & "." & Str(y)

'Increment the sequence number in TableApprovalNumber
DoCmd.SetWarnings (False)
DoCmd.RunSQL ("UPDATE TableApprovalNumber SET
TableApprovalNumber.Sequence = [Sequence]+1;")
DoCmd.SetWarnings (True)

End If 'If approved
End Sub

------

Jeff Beverly



On Fri, 13 Oct 2006 13:26:02 -0700, MikeSweet
<(E-Mail Removed)> wrote:

>Thanks for the quick response.
>Yeah...I thought of that but I need it to be dynamic. Here is what I have:
>1.) A request comes in from the field for work to be done
>2.) Engineer receives the order and if they approve then a number is
>assigned to that request
>3.) When they put in the date that the request is approved I take the last
>two numbers of the year adding it to the record number
>4.) This is what we call an ERS number
>5.) Right now my number looks like this: 1.2006, 2.2006, 3.2006
>6.) That number has to increment up to the end of each year starting over
>with one (i.e. 1.2005, 1.2006, 2.2006)
>7.) If the engineer doesn't approve it then it doesn't get a number but is
>still stored in the database table
>
>If I can have a number automatically be entered into a field when the
>request has been approved (APPROVED_NUMBER) and then attach it to the year
>but reset it to one when the year changes that would be good. I even thought
>of basing it on an hour/minute/day along with the year. I thought of the hour
>but more than one may be entered during that time.
>I'm stumped....
>Maybe it will come to me this weekend when I'm not thinking of it.
>
>"Jeff Boyce" wrote:
>
>> Mike
>>
>> It sounds like you want to use a number to "count", and to set up a field in
>> a table, and ....
>>
>> How about just using a query to count the annual number of requests where
>> Year(YourDateField) = 2006? (or whatever)
>>
>> Regards
>>
>> Jeff Boyce
>> Microsoft Office/Access MVP
>>
>> "MikeSweet" <(E-Mail Removed)> wrote in message
>> news7EB5458-B8FC-44AE-8AE4-(E-Mail Removed)...
>> >I need to have a number automatically created utilizing each record added
>> >to
>> > the year. I have it working now (based off the current reord plus the last
>> > two of the year) but the problem is I need it to start over at the end of
>> > each year. It should not be this difficult but I am stumped! We need to
>> > keep
>> > track of how many requests we have for each year. A user enters the data
>> > (could be many times an hour) then this is stored in the table. I am using
>> > ACCESS 2003.

>>
>>
>>

 
Reply With Quote
 
=?Utf-8?B?TWlrZVN3ZWV0?=
Guest
Posts: n/a
 
      17th Oct 2006
Yep...that worked. I must have had a brain freeze. Don't know why that one
was so difficult for me. Thanks for the help!

"Jeff Boyce" wrote:

> Mike
>
> It sounds like you want to use a number to "count", and to set up a field in
> a table, and ....
>
> How about just using a query to count the annual number of requests where
> Year(YourDateField) = 2006? (or whatever)
>
> Regards
>
> Jeff Boyce
> Microsoft Office/Access MVP
>
> "MikeSweet" <(E-Mail Removed)> wrote in message
> news7EB5458-B8FC-44AE-8AE4-(E-Mail Removed)...
> >I need to have a number automatically created utilizing each record added
> >to
> > the year. I have it working now (based off the current reord plus the last
> > two of the year) but the problem is I need it to start over at the end of
> > each year. It should not be this difficult but I am stumped! We need to
> > keep
> > track of how many requests we have for each year. A user enters the data
> > (could be many times an hour) then this is stored in the table. I am using
> > ACCESS 2003.

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
count a value in a date range based on a date in another workshee. marsjune68 Microsoft Excel Worksheet Functions 4 9th Apr 2009 10:31 PM
doing a query based on record count bd Microsoft Access Form Coding 1 5th Mar 2008 04:10 PM
Record count based on status kimberlyb Microsoft Access Reports 1 5th Feb 2008 10:17 PM
Record count based on criteria Lute Microsoft Access 1 10th Jan 2008 02:57 AM
Auto create record based on criteria and date in another record =?Utf-8?B?aG9tMzcw?= Microsoft Access 7 27th Sep 2007 02:17 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:43 AM.