Results 1 to 6 of 6
  1. #1
    DJDJDJDJ is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Dec 2011
    Posts
    21

    Issues with Reminders Query

    Hi,



    I have a small database to keep track of upcoming events. These events include recurring events such as birthdays etc. as well as one-time events such as passport renewal date. All these events are treated the same.

    Table is similar to below:

    RecID = Record ID, Auto number
    Event = Event Description, Text
    EventDate = Date of the event, could be in the past (birthday) or in future, Date Type
    ReminderDays = Number of days to be reminded of in advance.

    I have a query that looks at the upcoming events. It does not check for a fixed period, such as events in the next 2 weeks. Instead it checked to see if an event is coming up from today up until [ReminderDays]. This way each record can have its own reminder period.

    For example:
    1, "John BDay", 1-JAN-1970, 14
    2. "Passport Renewal", 15-JAN-2012, 30
    3. "Milly BDay", 2-JAN-1975, 5

    If today's date is 20-DEC-2011, then I will only see the first two records in the result-set.

    In my query, I am also calculating Age field by using a function.

    Query:
    Code:
     
    SELECT nextdate-date() AS [Days Until Event], *
    FROM (SELECT age([EventDate])+1 AS Age, dateadd("yyyy",Age,
     
    [EventDate]) AS NextDate, * FROM tblReminders WHERE (((Int(Format
    (DateAdd("d",-1,Date()),"yyyy\.mmdd")-Format
    ([EventDate],"yyyy\.mmdd")))<Int(Format(DateAdd("d",
     
    [ReminderDays],Date()),"yyyy\.mmdd")-Format
    ([EventDate],"yyyy\.mmdd")))) And removed=0 ) AS [%$##@_Alias]
     
    ORDER BY nextdate;
    Code:
    Public Function Age(dteDOB As Date, Optional SpecDate As Variant) As Integer
    Dim dteBase As Date, intCurrent As Date, intEstAge As Integer
    If IsMissing(SpecDate) Then
    dteBase = Date
    Else
    dteBase = SpecDate
    End If
    intEstAge = DateDiff("yyyy", dteDOB, dteBase)
    intCurrent = DateSerial(Year(dteBase), Month(dteDOB), Day(dteDOB))
    Age = intEstAge + (dteBase < intCurrent)
    End Function
    All seems to work except that if I have a future event that is not due for several years, it still shows in my list. Using the example above, I should not see the following record in my resultset.

    4. "Driving License Renewal", 5-JAN-2015, 30

    Any help is appreciated.

    Thanks.

  2. #2
    DJDJDJDJ is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Dec 2011
    Posts
    21
    help, please?

  3. #3
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,747
    What exactly is your question/issue?
    What would you like your set up to do?

    What exactly is your table definition?

  4. #4
    DJDJDJDJ is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Dec 2011
    Posts
    21
    Quote Originally Posted by orange View Post
    What exactly is your question/issue?
    What would you like your set up to do?

    What exactly is your table definition?

    Hello Orange,

    Here are answers to your question.

    I do not want to include any future events unless their due-date ([Event Date]) is between today and certain number of days ([ReminderDays]).

    Tables structure is given in my original post above. In the structure listing above, I am showing 4 fields. There are other fields in the table but they are irrelevant to this particular question.

    Thanks.

  5. #5
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,747
    Well the field "removed" is relevant since it is prompted for in your query.

  6. #6
    DJDJDJDJ is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Dec 2011
    Posts
    21
    Quote Originally Posted by orange View Post
    Well the field "removed" is relevant since it is prompted for in your query.

    Sorry, forgot to mention that field. Removed is a Y/N field to permanenty removing a listing from any of the results without actually deleting it from the DB.

    Thanks.

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

Similar Threads

  1. Query issues
    By goosegoose35 in forum Access
    Replies: 1
    Last Post: 12-08-2011, 06:43 AM
  2. Query Issues
    By Dale in forum Access
    Replies: 1
    Last Post: 11-29-2011, 01:35 AM
  3. Maintenance reminders using email (complex question)
    By avarusbrightfyre in forum Import/Export Data
    Replies: 1
    Last Post: 04-01-2011, 05:18 PM
  4. query issues
    By 9944pdx in forum Queries
    Replies: 3
    Last Post: 01-12-2011, 06:34 PM
  5. between query issues
    By jderrig in forum Queries
    Replies: 4
    Last Post: 01-15-2010, 02:30 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