Trouble with date calculation

G

Gary

I am trying to calculate a due date based on fields PickUpDate and
StdTransitBusDays.

I have the following function in Module DueDate (I took this from a search
on prior posts):

Public Function MyDateAdd(PICKUPDATE As Date, StdTransitBusDays As Integer)
As Date

Dim dtEnd As Date
Dim i As Integer


i = 0
dtEnd = PICKUPDATE

If StdTransitBusDays < 1 Then
Exit Function
End If


Do While i < StdTransitBusDays

dtEnd = dtEnd + 1
Select Case Weekday(dtEnd)
Case 2 To 6
' regular week day.MON - Fri..count one day
i = i + 1
End Select
Loop

MyDateAdd = dtEnd

End Function

And I have this line (from same post) in the after update event of the
StdTransitBusDays field:

me.DueDate = My DateAdd(me.PICKUPDATE,me.StdTransitBusDays

I don't get an error, just a blank field. Did I not translate the function
correctly into my own field names? Is the function called automatically or
do I need to code that?

Thanks.
 
S

StevenR via AccessMonster.com

Gary said:
I am trying to calculate a due date based on fields PickUpDate and
StdTransitBusDays.

I have the following function in Module DueDate (I took this from a search
on prior posts):

Public Function MyDateAdd(PICKUPDATE As Date, StdTransitBusDays As Integer)
As Date

Dim dtEnd As Date
Dim i As Integer

i = 0
dtEnd = PICKUPDATE

If StdTransitBusDays < 1 Then
Exit Function
End If

Do While i < StdTransitBusDays

dtEnd = dtEnd + 1
Select Case Weekday(dtEnd)
Case 2 To 6
' regular week day.MON - Fri..count one day
i = i + 1
End Select
Loop

MyDateAdd = dtEnd

End Function

And I have this line (from same post) in the after update event of the
StdTransitBusDays field:

me.DueDate = My DateAdd(me.PICKUPDATE,me.StdTransitBusDays

I don't get an error, just a blank field. Did I not translate the function
correctly into my own field names? Is the function called automatically or
do I need to code that?

Thanks.


I would try placing the function in the After Update event before you assign
the value to me.DueDate and see what happens.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top