How to display first item in databound combo

  • Thread starter Thread starter Ashish Kanoongo
  • Start date Start date
A

Ashish Kanoongo

I am using Access database and my tables are bound to forms. I m using a combo box in which i make user select one. i want to display the first item of the list as the default value. please suggest me how i can display as the 1st item of the list.
 
Set the Default Value to:
=[YourComboNameHere].[ItemData](0)

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

I am using Access database and my tables are bound to forms. I m using a
combo box in which i make user select one. i want to display the first item
of the list as the default value. please suggest me how i can display as the
1st item of the list.
 
I tried this in form load also, it is not working. As in my form_load and
"new Record " command button and set the focus to first field (tab order is
0 )and this combobox is having taborder 5, so it set default value but after
focus on first field, it loses the focus from combo box.

I think that is why it is not working.

Allen Browne said:
Set the Default Value to:
=[YourComboNameHere].[ItemData](0)

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

I am using Access database and my tables are bound to forms. I m using a
combo box in which i make user select one. i want to display the first item
of the list as the default value. please suggest me how i can display as the
1st item of the list.
 
You should be able to set the property for the combo in the Properties box.

If you are modifying the RowSource programmatically, try setting its Default
Value in the Current event of the form.

Just to be completely clear, Default Value applies to a new record only: it
has no effect on existing records where the value is Null.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Ashish Kanoongo said:
I tried this in form load also, it is not working. As in my form_load and
"new Record " command button and set the focus to first field (tab order is
0 )and this combobox is having taborder 5, so it set default value but after
focus on first field, it loses the focus from combo box.

I think that is why it is not working.

Allen Browne said:
Set the Default Value to:
=[YourComboNameHere].[ItemData](0)

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

I am using Access database and my tables are bound to forms. I m using a
combo box in which i make user select one. i want to display the first item
of the list as the default value. please suggest me how i can display as the
1st item of the list.
 
Allen

I hv already tried this also. However I am not using rowsource
programmatically, it is preassigned with controlsource properties.
..
Still I am not able to focus it.


Allen Browne said:
You should be able to set the property for the combo in the Properties box.

If you are modifying the RowSource programmatically, try setting its Default
Value in the Current event of the form.

Just to be completely clear, Default Value applies to a new record only: it
has no effect on existing records where the value is Null.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Ashish Kanoongo said:
I tried this in form load also, it is not working. As in my form_load and
"new Record " command button and set the focus to first field (tab order is
0 )and this combobox is having taborder 5, so it set default value but after
focus on first field, it loses the focus from combo box.

I think that is why it is not working.

Allen Browne said:
Set the Default Value to:
=[YourComboNameHere].[ItemData](0)

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

I am using Access database and my tables are bound to forms. I m using a
combo box in which i make user select one. i want to display the first item
of the list as the default value. please suggest me how i can display
as
the
1st item of the list.
 
Ashish,

If you data looks like this.

ID NameFirst NameLast
1 Bob Smith
2 John Jones

Where ID is the bound field. If you want Bob Smith to be the defualt, in
the default property of the combo box, put in "1". If you want John Jones
as the default use "2".

Kelvin

Ashish Kanoongo said:
Allen

I hv already tried this also. However I am not using rowsource
programmatically, it is preassigned with controlsource properties.
.
Still I am not able to focus it.


Allen Browne said:
You should be able to set the property for the combo in the Properties box.

If you are modifying the RowSource programmatically, try setting its Default
Value in the Current event of the form.

Just to be completely clear, Default Value applies to a new record only: it
has no effect on existing records where the value is Null.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Ashish Kanoongo said:
I tried this in form load also, it is not working. As in my form_load and
"new Record " command button and set the focus to first field (tab
order
is
0 )and this combobox is having taborder 5, so it set default value but after
focus on first field, it loses the focus from combo box.

I think that is why it is not working.

Set the Default Value to:
=[YourComboNameHere].[ItemData](0)

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

I am using Access database and my tables are bound to forms. I m
using
display
 
You may be able to use the Default Value property of the combo box to do
this if you're always starting on a new record. Put this expression in the
Default Value property for the combo box:

=[NameOfComboBox].ItemData(0)


--
Ken Snell
<MS ACCESS MVP>

I am using Access database and my tables are bound to forms. I m using a
combo box in which i make user select one. i want to display the first item
of the list as the default value. please suggest me how i can display as the
1st item of the list.
 
Back
Top