Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Increment a Short Time Field by 15 minutes

4 views
Skip to first unread message

croy

unread,
Nov 5, 2014, 4:26:00 PM11/5/14
to
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
entry.

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

dMax([CntTime],tblUseCountDetails,[UCDId]=me.txtUCDId)

... 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?

--
croy

John W. Vinson

unread,
Nov 5, 2014, 7:12:43 PM11/5/14
to
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:

http://answers.microsoft.com/en-us/office/forum/access?tab=question&status=all
http://social.msdn.microsoft.com/Forums/office/en-US/home?forum=accessdev
and see also http://www.utteraccess.com

croy

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