Results 1 to 3 of 3
  1. #1
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Ephrata, Washington, USA
    Posts
    683
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Add AutoDate field to Form Drop Down list (2003)

    Is there a way to add the autodate field as a drop down choice in a form field? I don't know how to use or write code, so I'm either looking for an easy answer or detailed instructions for how to do this with code. We want to populate the drop down box with specific dates and add one of the selections be to insert today's date. Can this be done?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Add AutoDate field to Form Drop Down list (2003)

    You can use code to insert today's date as one of the items in a dropdown list, but once inserted, it will be static. The item selected in a dropdown form field cannot be an automatically updating date field. Here is how to add today's date to the list:
    - Make sure the document is not protected for forms.
    - Double click the dropdown list and note its name (bookmark).
    - Click OK.
    - Protect the document.
    - Activate the Visual Basic Editor (Alt+F11)
    - Double click the ThisWorkbook item in the Explorer on the left hand of the window.
    - Enter or paste the following code:

    Private Sub Document_Open()
    With Me.FormFields("Dropdown1").DropDown.ListEntries
    .Clear
    .Add Date
    .Add #3/21/2005#
    .Add #4/2/2005#
    End With
    End Sub

    The line .Add Date adds today's date to the list; the others are fixed dates (modify and expand as needed.)
    Switch back to Word (Alt+F11) to test.

  3. #3
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Ephrata, Washington, USA
    Posts
    683
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Add AutoDate field to Form Drop Down list (2003)

    Thank you, Hans! That worked great. The only thing I noticed is that I can't have the form protected for forms until after I insert the code and then switch back to the document. Protecting it before inserting the code didn't seem to work. Thank you!! Works great. That's exactly what I needed.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •