Results 1 to 7 of 7
  1. #1
    ashraf_al_ani is offline Novice
    Windows 7 32bit Access 2003
    Join Date
    Aug 2014
    Posts
    6

    Reset a field when a new day starts


    Dear All
    i have a field called num1 type number
    is there a way to let that field start from 1 when a new day starts??

    so that field with every record will be increased by 1
    then it will be reset to 1 when a new day statrts

    best regards

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,522
    If you are talking about an autocounter and entering new data into a table,
    if your entry table is called tEntry
    have a copy of tEntry called tEntryMT (an empty table with autocounter field)

    start the day by copying tEntryMT to overwrite tEntry
    enter all data into tEntry (autocounter will start at 1)
    after day is done, post tEntry data to the perm table.

    repeat the next day.

  3. #3
    ashraf_al_ani is offline Novice
    Windows 7 32bit Access 2003
    Join Date
    Aug 2014
    Posts
    6
    Dear ranman
    The numbering should be automatic
    I mean every record opens the field will increase by one then when another day starts the field will set to one again
    I mean that every record has a number like restaurant system no matter if the number duplicate s in a diffrent day
    Best regards

  4. #4
    burrina's Avatar
    burrina is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383
    If I understand correctly you are going to calculate the date difference. Example Below. Of course you will then need to do what you want with the end result. If not Please explain further!

    myDiff: datediff("d", [thisDate], [thatDate])
    HTH

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,895
    Generating custom identifier is a common topic. Search forum. Start with

    https://www.accessforums.net/forms/a...ing-23329.html

    https://www.accessforums.net/access/...ers-21361.html
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    ashraf_al_ani is offline Novice
    Windows 7 32bit Access 2003
    Join Date
    Aug 2014
    Posts
    6
    Hi all
    pls i will re explain my problem again

    my project is access project front end access and back end sql server

    i have a field (num1) type integer in a table called (invoice)
    there is another field called inv_date type datetime in the same table

    i want num1 will be incremented by 1 when every record insert in the table in the same day

    num1 inv_date
    1 20/2/2014
    2 20/2/2014
    3 20/2/2014
    4 20/2/2014

    but when it becomes 21/2/2014 (next day)
    the num1 will starts again from 1 automatically and so on

    so please any ideas

    best regards

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,895
    I gave you ideas in the referenced links. I think one suggests something like:

    Nz(DMax("num1", "invoice", "inv_date=#" & Date() & "#"),0) + 1

    Try putting that in the DefaultValue property of textbox bound to num1.

    Why do you need this sequence number? Could calculate the sequence on a report. Textbox on report has a RunningSum property. It can be used to calculate sequence number.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 05-21-2014, 05:38 PM
  2. Reset autonumber field and delete records?
    By clebergyn in forum Programming
    Replies: 7
    Last Post: 02-20-2014, 07:32 PM
  3. Reset autonumber in a concatenate field
    By Fish218 in forum Forms
    Replies: 6
    Last Post: 03-13-2012, 11:58 AM
  4. How to add ID 1 above table that starts with ID 2 ?
    By Plomo in forum Database Design
    Replies: 2
    Last Post: 09-03-2009, 12:19 PM
  5. Replies: 5
    Last Post: 08-07-2009, 05:23 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums