delete date range

jeo

Registered User.
Local time
Today, 16:08
Joined
Dec 26, 2002
Messages
299
I'm still struggling with deleting date range.
I got a lot of help and finally got it to populate a range of dates.
What i need help with is deleting that date range if user makes any changes.

Let's say user originally selected Start-01/02/05 through End -01/05/05.
Fill in between code that Brianwarnock helped me with fills in
01/02/05
01/03/05
01/04/05
01/05/05
in a tblDatesNew - Start variable.
Now if a user comes in and decide to change original start date from 01/02/05 to something else (it could be 01/01/05 or 01/03/05), is there a way to trigger an after_update event that will delete all current dates out of Start variable in tblDatesNew?
Here is the code that Brianwarnock helped me with to add dates, and I'm thinking that code should be somewhat similar to delete those dates.

Set rstOrig = CurrentDb.OpenRecordset("tblDates", dbOpenDynaset)
Set rstNew = CurrentDb.OpenRecordset("tblDatesNew", dbOpenDynaset)

rstOrig.MoveFirst

checkDateID:
If rstOrig("DateID") <> Me.DateID Then
rstOrig.MoveNext
GoTo checkDateID
End If
SDate = rstOrig("Start")
EDate = rstOrig("End")
If IsNull(EDate) Then
GoTo Quit
End If
TestDate = SDate
Do
rstNew.AddNew
rstNew("DateID") = rstOrig("DateID")
rstNew("Start") = TestDate

rstNew.Update
TestDate = TestDate + 1
Loop Until TestDate > EDate

Quit:
rstOrig.Close
rstNew.Close
End Sub
Thank you!
 
I decided not to use the code and in stead use a Delete query that runs after updating that field and it works great.
Please let me know if you think that code would be better than my delete query.
Thanks everyone!
 

Users who are viewing this thread

Back
Top Bottom