Share via

Combo box default value in Access form

Anonymous
2012-11-09T03:39:20+00:00

Hi,

I have a combo box (named 'Disposition') on an Access form whose data source is a query.  I want to specify the first item in the query as the default value.

I thought the way to do this was to set the following property:

Default Value:  =Disposition.ItemData(0)

I've tried this, but it still defaults to blank for newly inserted data items.

Also tried:

Default Value:  =[Disposition].ItemData(0)

Default Value:  =Disposition.ItemData

Default Value:  =[Disposition].ItemData

Default Value:  Disposition.ItemData(0)

Default Value:  Disposition.ItemData

Default Value:  [Disposition].ItemData

Any idea why this might be failing?

Thanks!

Emily

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

3 answers

Sort by: Most helpful
  1. Anonymous
    2012-11-09T18:06:11+00:00

    If the combo box is an unbound control, while you can set the DefaultValue property of an unbound control, it's much the same as assigning an initial value to it, so in the form's Load event procedure you can put:

        Me.Disposition= Me.Disposition.ItemData(0)

    If it's a bound control then you could put the following in the form's Load event procedure rather than setting the property in the properties sheet:

        Me.Disposition.DefaultValue = """" & Me.Disposition.ItemData(0) & """"

    Note that the DefaultValue property is always a string expression, regardless of the data type of the column to which it is bound, hence the literal quotes.

    Was this answer helpful?

    5 people found this answer helpful.
    0 comments No comments
  2. Anonymous
    2012-11-09T04:47:41+00:00

    Try using the same SQL but set 'TOP 1' for the default.

    Was this answer helpful?

    2 people found this answer helpful.
    0 comments No comments
  3. Anonymous
    2012-11-09T14:45:55+00:00

    I don't see why that doesn't work.

    Don't forget that the DefaultValue property is only evaluated and used on a new record at the time you enter the first character in some bound control.  If you are expecting anything else, it won't do whatever it is you wanted it to do.

    BTW, all six of the things you tried are valid syntax for the same thing.

    Was this answer helpful?

    0 comments No comments