Combo Box (2 column) default

  • Thread starter jer99 via AccessMonster.com
  • Start date
J

jer99 via AccessMonster.com

On opening a form I populate a combo box using an array(0,0) - I
dimenensioned the array as a variant.
The 1st column is a date field and the second column is a string
I make the length of the second column 0 so that it is not seen, but still
useful.

I have tried to set the default value to the first element:
Me.cboFDBDates.DefaultValue = Me.cboFDBDates.ItemData(1)
Problem is I think its displaying the result of a division rather than seeing
it as a date.

What am I doing wrong?
 
D

Dirk Goldgar

jer99 via AccessMonster.com said:
On opening a form I populate a combo box using an array(0,0) - I
dimenensioned the array as a variant.
The 1st column is a date field and the second column is a string
I make the length of the second column 0 so that it is not seen, but
still useful.

I have tried to set the default value to the first element:
Me.cboFDBDates.DefaultValue = Me.cboFDBDates.ItemData(1)
Problem is I think its displaying the result of a division rather
than seeing it as a date.

What am I doing wrong?

Try:

Me.cboFDBDates.DefaultValue = _
Chr(34) & Me.cboFDBDates.ItemData(1) & Chr(34)

or else

Me.cboFDBDates.DefaultValue = _
"#" & Me.cboFDBDates.ItemData(1) & "#"

I suspect that either will work.

The DefaultValue property is a string that will be evaluated to get the
default value, with the result of the evaluation being converted to the
necessary data type. For anything but a simple number or a function
reference, you have to make sure it is evaluated properly.

E.g.,

?Eval("10/4/2006")
1.24626121635095E-03
?Eval("""10/4/2006""")
10/4/2006
 
Top