I'm trying to use
=Month([tran_date])
as the default value in a list box, where [tran_date] has just been entered as the previous field on a new record and is therefore not saved yet.
Doesn't seem to make this work though. Can anyone help please
Thanks
Colin
Month command
-
- Administrator
- Posts: 78621
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Month command
The Default Value of a property is set when you move to a new record. At that moment, tran_date has not been entered yet, so the default value of the list box is null (empty).
You could create an After Update event procedure for tran_date:
Replace ListBox1 with the actual name of your list box. The code only sets the value of the list box if you're on a new record and if nothing has been selected in the list box yet.
You could create an After Update event procedure for tran_date:
Code: Select all
Private Sub tran_date_AfterUpdate()
If Me.NewRecord And Me.ListBox1.ListIndex = -1 Then
Me.ListBox1.Value = Month([tran_date])
End If
Best wishes,
Hans
Hans
-
- StarLounger
- Posts: 65
- Joined: 01 Apr 2011, 18:43
Re: Month command
Thank you.
As ever, excellent speed and help. It works perfectly.
Many thanks, it is appreciated
As ever, excellent speed and help. It works perfectly.
Many thanks, it is appreciated