Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6230665
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:47:26+00:00 2026-05-24T09:47:26+00:00

How do we bind a date field to a combobox (with Row Source Type

  • 0

How do we bind a date field to a combobox (with Row Source Type = Value List)?

We setup the combobox like this in the Form Load in VBA:

For i = 0 To 6
    Dim strValueMember As String
    Dim strDisplayMember As String
    strValueMember = format(DateAdd("d", 0 + i, anchorDate), "dd-MMM-yy") & ";"
    strDisplayMember = format(DateAdd("d", 0 + i, anchorDate), "ddd dd-MMM-yy") & ";"
    strItems = strItems & strValueMember & strDisplayMember

Next i
strItems = Left(strItems, Len(strItems) - 1)

Me.cboDeliveryDate.RowSource = strItems

This gives us a neat little combobox with the user able to pick from a list of 7 days. As a bonus he gets to see the day of the week (actually, for this end user, day name is quite important).

enter image description here

The combobox has two columns, a value column (for true date) and a display column (to show the day name).


But there are problems whichever Bound Column we set:

If we set the Bound Column to column 0, it apparently works, but the value stored is 31/12/1899, 1/1/1900, 2/1/1900 etc. So it’s just reading the combo’s listindex and converting that to a date.

If we set the Bound Column to column 1, it does actually work in that the selected value is written back to the database. But it is never displayed on the form, so the user obviously won’t feel that his edit has taken

If we set the Bound Column to column 2, we get a Not In List error.


All the above apply whether or not we use dd-MMM-yy for strValueMember or (as @HansUp answer suggests, yyyy-m-d).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T09:47:27+00:00Added an answer on May 24, 2026 at 9:47 am

    Looks to me like cboDeliveryDate has 2 columns, with strValueMember as the first and it is also the bound column, bound to a Date/Time field. This worked for me by formatting strValueMember in a yyyy-m-d date format.

    Private Sub Form_Load()
        Dim i As Long
        Dim anchorDate As Date
        Dim strValueMember As String
        Dim strDisplayMember As String
        Dim strItems As String
    
        anchorDate = Date
    
        For i = 0 To 6
            strValueMember = Format(DateAdd("d", i, anchorDate), _
                "yyyy-m-d") & ";"
            strDisplayMember = Format(DateAdd("d", i, anchorDate), _
                "ddd dd-MMM-yy") & ";"
            strItems = strItems & strValueMember & strDisplayMember
        Next i
        strItems = Left(strItems, Len(strItems) - 1)
        Me.cboDeliveryDate.RowSource = strItems
    End Sub
    

    I didn’t know where anchorDate comes from, so I just substituted today’s date.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to bind a list of custom objects to a WPF Image like
I had grid view which bind sql data source and added field to update
I am using the vanilla datepicker in Silverlight 2. I bind the selected date
I bind the ItemsSource of a ComboBox to an ObservableCollection<MyClass> . In code I
I'd like to bind a configuration file to my executable. I'd like to do
If I want to bind a collection to a some form of listing control
I'm trying to bind controls in a WPF form to an interface and I
i have one hidden field and i want to bind it with two values
I'm binding the jquery datepicker to an input field. This works fine with static
I'm attempting to bind a RadPanelBar to a flat data source in Silverlight. All

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.