How do I get my textbox field in my form to automatically enter data based on another textbox in Access 2019?

Arreya Ahrom 1 Reputation point
2021-09-22T14:13:40.26+00:00

I'd like to populate a "month" textbox based on an entered "date" textbox. How do I go about doing this?

e.g. I enter "02/02/21" in my "date" textbox and then I press tab to the "month" textbox which will automatically fill in "February". This month would then be saved in its corresponding field in my record source.

Access Development
Access Development
Access: A family of Microsoft relational database management systems designed for ease of use.Development: The process of researching, productizing, and refining new or existing technologies.
858 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. DBG 2,301 Reputation points
    2021-09-22T16:53:41.16+00:00

    Hi. The "month" textbox is a "calculated" value, so there's really no need to store it in the table (it's actually against normalization rules).

    To automatically display the month, you can use something like:

    =Month([DateTextboxName])

    0 comments No comments

  2. Ken Sheridan 2,756 Reputation points
    2021-09-23T11:57:31.943+00:00

    Bind the 'month' text box to your date field and make it read only by setting its properties as follows:

    ControlSource: [NameOfYourDateField]
    Format: mmmm
    Enabled: No
    Locked: Yes

    Once a valid date is entered into the date field the month text box will show the corresponding month.

    The month field should be deleted from the table as it is redundant, being determined by the date field, and thus means that the table is not normalized to Third Normal Form (3NF), with the consequent risk of update anomalies.

    0 comments No comments