Hello:
I have written a couple of public functions in a separate module that I call in the select statement of a qdef. They are used to populate values in a form that runs when the user clicks a button.
All is well with the exception of the End_Date calculation. The code for the functions is:
Option Compare Database
==========================================================
Public Function fcnEndTime(HoldTime As String, RampTime As String, StartTime As String)
fcnEndTime = Format(DateAdd("n", (60 * [HoldTime] + 60 * [RampTime]), [StartTime]), "Long Time")
End Function
==========================================================
Public Function fcnEndDate(StartTime As String, EndTime As String, SchedDate As String)
fcnEndDate = Format(DateAdd("n", Abs(DateDiff("n", [StartTime], [EndTime])), [SchedDate]), "Short Date")
End Function
The problem occurs whenever the End_Time goes past midnight. If an event starts at 1:00 p.m. on 5/1/2006 and the HoldTime is 12 hours and the RampTime is .5 hours, then the end time correctly returns 1:30 a.m. However, the End_Date remains the same as the SchedDate when it really should be 5/2/2006.
I really am not sure how to roll the date forward. Any suggestions or ideas are most appreciated. Btw, I have tried to make my code a little more readable up above. But I've seen some posts where the code appears to be embedded in the the message body. This makes posts much more readable. Can anyone please tell me how to do this?
-Ben
I have written a couple of public functions in a separate module that I call in the select statement of a qdef. They are used to populate values in a form that runs when the user clicks a button.
All is well with the exception of the End_Date calculation. The code for the functions is:
Option Compare Database
==========================================================
Public Function fcnEndTime(HoldTime As String, RampTime As String, StartTime As String)
fcnEndTime = Format(DateAdd("n", (60 * [HoldTime] + 60 * [RampTime]), [StartTime]), "Long Time")
End Function
==========================================================
Public Function fcnEndDate(StartTime As String, EndTime As String, SchedDate As String)
fcnEndDate = Format(DateAdd("n", Abs(DateDiff("n", [StartTime], [EndTime])), [SchedDate]), "Short Date")
End Function
The problem occurs whenever the End_Time goes past midnight. If an event starts at 1:00 p.m. on 5/1/2006 and the HoldTime is 12 hours and the RampTime is .5 hours, then the end time correctly returns 1:30 a.m. However, the End_Date remains the same as the SchedDate when it really should be 5/2/2006.
I really am not sure how to roll the date forward. Any suggestions or ideas are most appreciated. Btw, I have tried to make my code a little more readable up above. But I've seen some posts where the code appears to be embedded in the the message body. This makes posts much more readable. Can anyone please tell me how to do this?
-Ben