Define a form with two text boxes on it: tbxD and tbxOut.
Put the following th tbxD's AfterUpdate event:
Code:
Dim dDate As Double
dDate = CDbl(tbxD) 'Convert date/time to Double
dDate = CDbl(CInt(dDate * 96)) / 96 'Take the integer part of the number of
'15-minute intervals in a day to round
Me.tbxOut = CDate(dDate) 'Convert back to date
Enter a valid time in tbxD and the rounded time will appear in tbxOut.
Was all set to provide another solution when I realized
yours was better. After playing with it for a while,
found that it could be easily reduced to a small function, e.g.
Code:
Function RoundTime(pTime As Variant) As Date
Dim tHold As Date
'allows user to input either a valid time or a string
thold = TimeValue(pTime)
RoundTime = CDate(CDbl(CInt(CDbl(thold) * 96)) / 96)
End Function