Results 1 to 11 of 11
  1. #1
    MikeWooZ is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Nov 2011
    Posts
    4

    Increment a number by "1"... once everyday

    I have a database that I import Excel data into. Within the imported data, I have a field that holds a number that indicates how many days a person has been in a program. I don't want this number to increment every time I open the form, but I want it to increment on the next days date change.



    In other words, today, the data on the form would reflect "10" and if my supervisor views the report a week from now, I want it to reflect "17"... even though I've opened the form a hundred times.

    Is there a fairly easy way to accomplish this task without setting a bunch of queries and sql tables?

    Thanks in advance for any and all advice.

  2. #2
    Rainlover's Avatar
    Rainlover is offline Expert
    Windows 7 64bit Access 2003
    Join Date
    Nov 2009
    Location
    Queensland Australia
    Posts
    691
    Simply Substract one Date from the other.

    Use the Function Date Diff.

    Search Functions for Date.

  3. #3
    MikeWooZ is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Nov 2011
    Posts
    4

    No fields contain date type data

    That would be easy if I had some date fields to compute off of. All I have is data extracted from a data source that only provides the amount of days, in other words, the source already used the date to calculate the numerical field provided.

    As stated, all I have to work with is a number, and I need to be able to increment that number by one.... tomorrow.

    Thanks for your feedback.

  4. #4
    Rainlover's Avatar
    Rainlover is offline Expert
    Windows 7 64bit Access 2003
    Join Date
    Nov 2009
    Location
    Queensland Australia
    Posts
    691
    Does this number represent a Date.

    Dates are usually just number of Days since 30 Dec 1899.

    If this number is really a Date then you could convert Today's Date to a Number and then find the Difference.

    The Function to do this is "DateValue". (But just check help to see if I have the correct Value.

    Also look here

    http://www.techonthenet.com/access/f.../datevalue.php

  5. #5
    MikeWooZ is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Nov 2011
    Posts
    4

    Not a date

    From all the responses, I wish it was a date, but unfortunately it is not. It is a calculated number whereas the source has already performed the "total days" calculated value. This almost seems like it should be too easy... just pick a field and 1 to it everyday.

    Please keep pumping me your thoughts for I hope one of you will present a really good solution.

    Thanks again Rainlover for all your responses thus far.

  6. #6
    hertfordkc is offline 18 year novice
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    481

    This might be using an axe when you need a file, but

    you could schedule a command line to start your database, execute a macro that increments the day, and closes the database.

  7. #7
    MikeWooZ is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Nov 2011
    Posts
    4
    Could you elaborate a bit on how to do this... if not, would you know of a good source for this info?

    Thank you

  8. #8
    hertfordkc is offline 18 year novice
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    481

    I can give a little help, but some of my experience is fading.

    First of all, you can run a scheduler from windows. I can't remember whether you can specify a command line or if you need a batch file, so let's assume you create a batch file that will be started by the scheduler.
    Mybatch.bat
    C:\Pathname\Mydatabase /x MydateMacro //Google Access Command Line for your options here

    This starts Mydatabase and runs MydateMacro

    MydateMacro // Google macro actions for explanation of runcode
    Runcode MyVBADateFunction()
    CloseDatabase

    The Runcode assumes that you can write the VBA code needed to increment the days. Perhaps this won't be necessary, i.e. maybe running a query can do the job. I wasn't sure from the posts exactly where the days to be incremented were located.

  9. #9
    Rainlover's Avatar
    Rainlover is offline Expert
    Windows 7 64bit Access 2003
    Join Date
    Nov 2009
    Location
    Queensland Australia
    Posts
    691
    I could make a hundred guess and still get it wrong. So I am not going to do that.

    It would help to have a sample of a few lines of your Data.

    Also an explanation of how you know what Data to display. There must be something unique in your data source or you would show all the data all the time.

  10. #10
    ChrisO is offline Novice
    Windows XP Access 2003
    Join Date
    Aug 2005
    Location
    Brisbane, Australia
    Posts
    27
    MsgBox CLng(Date) – 40868

    Edit:
    Or more correctly:-
    MsgBox CLng(Date) - 40878 + field_that_holds_a_number

    It may be safer to get the date from the server to stop people interfering with the result by changing the date on their local machine.

    Chris.

  11. #11
    hertfordkc is offline 18 year novice
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    481

    What I posted earlier was a scheme to update a count every day,

    whether you opened the database or not.
    If you really wanted to count the days on which you opened the database, create RefData Table
    LastUpdate
    Count

    When you open the database, first thing happens is the Lastupdate is checked to see if it is less than today. If it is, make lastupdate = today, and increment the count.
    Go on about your business.

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

Similar Threads

  1. Replies: 8
    Last Post: 08-05-2011, 02:55 PM
  2. Replies: 16
    Last Post: 07-22-2011, 09:23 AM
  3. Fill-in from Badge "number"
    By WestofYouLB in forum Access
    Replies: 2
    Last Post: 04-15-2011, 05:21 PM
  4. "Group By" causes "ODBC--Call Failed" error
    By kaledev in forum Queries
    Replies: 1
    Last Post: 03-09-2011, 02:43 PM
  5. Replies: 21
    Last Post: 06-03-2009, 05:54 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