Combo Box Default Date

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

jackson via AccessMonster.com

Hi,

I have a combo box in a form that is used to run data as at a certain point
in time. I want this to be selectable, ie the use of a combo box, plus I want
the default value to be the most recent date/time. I don't know how to go
about doing this though...any help would be appreciated.

Cheers.
 
If you use a query for the Row Source to fill the combo box with the
available dates and sort on the date so that the most recent date is listed
first, you can then set the DefaultValue of the combo box to

=[NameOfCombobox].[Column](0,0)

The first number is the number of the Bound Column minus 1 (zero based), the
second number is the number of the row in the drop down list minus one (zero
based, 0 is the first row, 1 is the second, etc).
 
PS, the previous suggestion will only work if the combo box is bound. If it
isn't, then in the form's Load event, set the value of the combo box to its
first row instead of doing it with the DefaultValue property.

Me.NameOfCombo = Me.NameOfCombo.Column(0,0)
 
Thanks Guys,

Got this working now - the default. Quick quesiton, when I import new data,
it assigns a timestamp on now() which I'm using as criteria (off the said
form). After I import, I want the default value to update as it's now changed
to the latest time value.

Any ideas how to do this short of having my import code close the form then
re-open it? Requery nor Refresh seem to work...

Thanks guys.
 
After the import, you should be able to have the code requery the combo box
then set the value.

Example:
Me.cboMyCombo.Requery
Me.cboMyCombo = Me.cboMyCombo.Column(0,0)
 
Back
Top