Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Every third (3) week on Thursday...

Posted on 2003-12-04
6
Medium Priority
?
333 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
Independent Software Vendors: 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 200 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

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!

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

715 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