Solved

Every third (3) week on Thursday...

Posted on 2003-12-04
6
331 Views
Last Modified: 2011-09-20
Hello All,

I have no idea how to begin to have my application retrieve records based on the following:

In the options section of my application the app user can choose to have a [reminder] set to notify them (say) "Every 3 weeks on a Thursday.' I have the following fields created.

Start Date, Number of Weeks, chkSun, chkMon, chkTue, chkWed... all seven days.

How can I recall [as a reminder] this data [Every 3 weeks on a Thursday] ?

Please remember that number of weeks and days will change per the app user.

Please, any ideas?

Adawn

0
Comment
Question by:ADawn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
6 Comments
 
LVL 10

Expert Comment

by:ADSaunders
ID: 9873852
Firstly, There's no point in pre-calculating the reminder dates. How far forward would you calculate, and what if the user changes his/her options?

I would have another field 'Next Reminder', and would calculate it every time the reminder triggered, and every time the options were changed. then the logic for triggering a reminder is simply ' is it today? ' or :
if Next Reminder = date() then .....

Then I would trim the day variables to a single integer where 1 = Sunday and 7 = Saturday (say Wday).

Then the calculation becomes:

Next Reminder = date() + (Number of weeks * 7)
Today = DatePart("w", date())
if Wday - Today < 0 then     Next Reminder = Next Reminder + 7
Next Reminder = Next Reminder + Wday - Today

.. Any Use??
.. Alan
0
 
LVL 26

Expert Comment

by:EDDYKT
ID: 9874032
Just do date add on your start date


ie

dateadd("d", 21, startdate)
0
 

Author Comment

by:ADawn
ID: 9874526
OK guys,

I'll need a little time to digest this stuff. I'm get back with you soon - I hope :).

Thanks,
ADawn.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 10

Accepted Solution

by:
ADSaunders earned 50 total points
ID: 9874802
Hi,
My previous comment was written 'on the fly'. Just to prove it worked, icopied the pseudocode into a VB project, corrected syntax errors, and it ran first time:

Dim NextReminder As Date
Dim WDay As Integer ' Day of week 1=Sun, 2=Mon etc ... 7 = Sat
Dim Today As Integer
Dim NumberOfWeeks As Integer

NumberOfWeeks = 3 ' Required reminder 3 Weeks
WDay = 2                 '     "              "       on Monday
NextReminder = Date + (NumberOfWeeks * 7) 'Calculate date n weeks ahead (current day)
Today = DatePart("w", Date)  ' find todays day number
If WDay - Today < 0 Then NextReminder = NextReminder + 7 ' * See Note
NextReminder = NextReminder + WDay - Today ' Add the difference between required day and today
MsgBox NextReminder

* Note This line is only required if reminder is wanted '3 weeks NEXT Monday' In My tests I checked today (4/12/2003 if you're English, or 12/4/2003 if you're American):

With this line NextReminder was 29/12/03 (12/29/03)
Without this line NextReminder was 22/12/03 (12/22/03)

.. Alan
0
 
LVL 26

Expert Comment

by:EDDYKT
ID: 9874934
How about this

Dim WDay As Integer ' Day of week 1=Sun, 2=Mon etc ... 7 = Sat
Dim NumberOfWeeks As Integer

NumberOfWeeks = 3 ' Required reminder 3 Weeks
WDay = 2                 '     "              "       on Monday
MsgBox DateAdd("d", NumberOfWeeks * 7 + WDay - Weekday(Now) + 7, Date)
0
 

Author Comment

by:ADawn
ID: 9893562
Lots of stuff to work with. Thanks to all!

ADawn
0

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question