473,395 Members | 1,418 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Repeat a scheduled event

I am new to coding and therefore don't have much experience.

My problem is this:

I have a date field and other fields within a table.
I want to schedule a certain event but to have it REPEAT either weekly
(every Wednesday) or daily (monday thru friday) until a certain date (Mar
31, 2004 or 1 year or 16 weeks)

What coding should I use or is there a template or macro that can do this
for me?

Any help on this matter would be appreciated.
You could also email me the info to: ak****@charter.net

Thank you in advance for the help.
Nov 12 '05 #1
2 2379
"A & K Merchandise" <ak****@charter.net> wrote in message news:<vq************@corp.supernews.com>...
I am new to coding and therefore don't have much experience.

My problem is this:

I have a date field and other fields within a table.
I want to schedule a certain event but to have it REPEAT either weekly
(every Wednesday) or daily (monday thru friday) until a certain date (Mar
31, 2004 or 1 year or 16 weeks)

What coding should I use or is there a template or macro that can do this
for me?


The only way I can think of doing it is to write a module that will do
it. The problem is that you need to create a looping structure, and
those aren't that easy in macros. The kicker is the "do it only on
weekdays". AFAIK, there's no way to do that without code.
Nov 12 '05 #2
Ok, here's some really ugly code that really should be in a module by
itself, and with proper error handling.

It should really be in a subroutine in a code module, not in code
behind a form, but I didn't do it that way...

Sub ScheduleEvents(ByVal dtmStartFirst As date. ByVal dtmFinishFirst
As Date, ByVal dtmStartLast as Date, ByVal intFrequency as Integer)

so that the logic/processing is totally separate from the form...

Option Compare Database
Option Explicit

Private Sub cmdCreateEvents_Click()
Dim dtmStartFirst As Date
Dim dtmFinishFirst As Date
Dim dtmStartLast As Date
Dim dtmThis As Date

Dim strEvent As String
Dim sngDuration As Single
Dim intFrequency As Integer

Dim dbs As DAO.database
Dim rst As DAO.Recordset

If IsDate(Me.txtStart) And IsDate(Me.txtFinish) Then

intFrequency = CInt(Me.Combo4)
dtmStartFirst = CDate(Me.txtStart)
dtmFinishFirst = CDate(Me.txtFinish)
dtmStartLast = CDate(Me.txtDateLast)

sngDuration = DateDiff("n", dtmStartFirst, dtmFinishFirst)
strEvent = Me.txtEventName

Set dbs = DBEngine(0)(0)
Set rst = dbs.OpenRecordset("tblEvent", dbOpenTable)

dtmThis = dtmStartFirst

Do Until dtmThis > dtmStartLast + 1

If Weekday(dtmThis) <> vbSaturday And Weekday(dtmThis) <>
vbSunday Then
rst.AddNew
rst.Fields("EventStart") = dtmThis
rst.Fields("EventFinish") = DateAdd("n", sngDuration,
dtmThis)
rst.Fields("EventName") = strEvent
rst.Update
End If

'imcrement date
dtmThis = DateAdd("d", intFrequency, dtmThis)

Loop
Else
MsgBox "You must supply a valid start and end date."
End If

rst.Close
Set rst = Nothing
Set dbs = Nothing
End Sub
Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: A. Lovhaug | last post by:
I have a console application built in the .NET Framework. This application basically executes an XCopy based on parameters that I pass to it. I use it for creating scripts for backing up folders,...
2
by: David Olive | last post by:
Hi guys, I'm having a bit of a problem getting a VB .NET console app to run happily as a scheduled task. The app itself generates a bunch of word documents on a file share on another server by...
11
by: Peter Neumaier | last post by:
Hi! I scheduled a DTS-Import from MySQL, whenever I run it manually (Right-Click on the DTS package) it runs through without any problems. But firing it by a schedule doesn't work!? Just to...
1
by: satelite | last post by:
Hello, I am writing an exe that is intended to be run via a scheduled task. However, I also need the flexibility to have users run the scheduled task manually (right click task and select run). ...
0
by: Satish | last post by:
Scheduled Tasks (.Net ) does not run when server is logged off (Windows 2003): I have a .net executable (command line exe) which performs certain business operations. I can run the program...
1
by: roveagh1 | last post by:
Hi I've been using the 2 year old link below to repeat values from previous record field into current corresponding field. It's worked fine for text but the last piece of advice was to use the same...
0
by: Myster Edd | last post by:
I have a strange problem that I think deals with security on SQL 2005. I have a scheduled task that runs on a Windows 2000 machine. It calls a vb script which creates a connection to SQL Server. ...
1
by: Myster Edd | last post by:
I have a strange problem that I think deals with security on SQL 2005. I have a scheduled task that runs on a Windows 2000 machine. It calls a vb script which creates a connection to SQL Server. ...
7
by: whutto | last post by:
I have a VB.NET app that crashes when run from the Windows scheduled tasks, but runs fine when the run-as user is logged on. The app also runs fine from the scheduled jobs if the run as user is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.