2

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

HansUp
  • 95,961
  • 11
  • 77
  • 135
  • You should never store a month as a localised literal. Use the month index, 1 to 12, which also is sortable. Also, consider using a _callback_ function for such tasks. Se examples in my project: [VBA.Callback](https://github.com/GustavBrock/VBA.Callback). – Gustav Dec 01 '21 at 06:30
  • Thanks alot @Gustav, I noticed your point in Most solutions I found while researching about it. I would love to see an actual example in which month indexes are are applied. I would appreciate if you would kindly give me that alternative. – Clyde Mulenga Dec 02 '21 at 08:01

2 Answers2

1

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()))
HansUp
  • 95,961
  • 11
  • 77
  • 135
1

Use following expression to default value property-

=Format(Date(),"mmmm")

enter image description here

Harun24hr
  • 30,391
  • 4
  • 21
  • 36