Increment a Short Time Field by 15 minutes

Skip to first unread message


Nov 5, 2014, 4:26:00 PM11/5/14
On a data-entry subform, it would be helpful to set the
default for a time field to be 15 minutes more than the last

I've tried to put code on the AfterUpdate event of the
txtCntTime field like this:


... but just get "0:00" in the textbox.

I also tried a variant of that in the default property for
txtCntTime, but just got "#Name?" in the textbox.

Any thoughts?


John W. Vinson

Nov 5, 2014, 7:12:43 PM11/5/14
The arguments to DMax() (and all the domain functions) must be text strings:
the first the name of a field, the second the name of the Table or Query
containing that field, and the (optional) third argument a valid SQL WHERE
clause (without the WHERE keyword) specifying which record in the table/query.

However, your dMax expression does not do what your intro specifies. If you
really want to set the default value to 15 minutes after the maximum CntTime,
you could use:

Private Sub txtCntTime_AfterUpdate()
If Not IsNull(Me!txtCntTime) Then ' only set default if a value exists
Me!txtCntTime.DefaultValue = Chr(34) & _
Format(DateAdd("n", 15, Me!txtCntTime), "hh:nn") & Chr(34))
End If
End Sub

This assumes that CntTime is a pure time value such as 10:35; if it's a date
and time value, use a Format of "yyyy-mm-dd hh:nn".

Note the suggestions in my .sig - this forum was killed off by Microsoft
several years ago, and exists only in the dark underworld of Usenet Zombie
Newsgroups. This is the first post I've seen here in some months.

John W. Vinson [MVP]
Microsoft's replacements for these newsgroups:
and see also


Nov 10, 2014, 9:37:23 AM11/10/14
Very nice! Thank you for your response. Works like a
Reply all
Reply to author
0 new messages