Home > database >  Set default value in a Microsoft Access combo box to current month
Set default value in a Microsoft Access combo box to current month

Time:12-01

I have a column "Month" in my MS Access 2016 Database Record whose month value say "January" or "February" should be entered using a combo box with the following;

Row Source Type: Value List

Row Source: "January";"February";"March";"April";"May";"June";"July";"August";"September";"October";"November";"December"

Default Value: Month(Date())

However, to simplify work, most months will be entered in the actual current month, this can also be changed using a combo box selection in a case where it is an old entry, the combo box is working just fine, unfortunately, '''Month(Date())''' is not working but only populating the field with the whole string "Month(Date())" as the entry.

What should I put on my Default Value in order for this combo box to automatically return the current month in words, like "January" or "February" .

CodePudding user response:

If you want to use an expression in the Default Value property, precede the expression with an equal sign like this:

=Month(Date())

That would give you the month number of the current date. However it sounds like you actually want the month name instead. In that case feed the month number to the MonthName() function:

=MonthName(Month(Date()))

CodePudding user response:

Use following expression to default value property-

=Format(Date(),"mmmm")

enter image description here

  • Related