Add value to comb box

  • Thread starter Thread starter James B
  • Start date Start date
J

James B

Hi all,

How do I add the values to the combo box using programming?
And show only the name and hide the rest? I'm trying to do
a select query from the user table and from the query
result, I apply the result to the combo box.

Let say,

Dim rd as dao.database
dim rst as dao.recordset
dim str as string

str = "SELECT userId,uname FROM USER"

set rd=currentdb()
set rst=rd.openrecordset(User)

If rst.RecordCount > 0 Then

With Me.combox1
.RowSourceType="Table/query"
.RowSource=str
//From Here, How do I show only the user name and not
the user ID ??

end with

Thanks,

J.B.
 
James

Have you looked at the control properties for the combo box? Specifically the Column Count under the Format Tab. If you set this to 1 it will only show 1 column

HTH

John
 
Yes I did. But I also like to know how to do show the
column using programming. And with that, I need to know
how to hide the userId column and show the username column.

Thanks for the help.

J.B.
-----Original Message-----
James,

Have you looked at the control properties for the combo
box? Specifically the Column Count under the Format Tab.
If you set this to 1 it will only show 1 column.
 
James said:
How do I add the values to the combo box using programming?
And show only the name and hide the rest? I'm trying to do
a select query from the user table and from the query
result, I apply the result to the combo box.

Let say,

Dim rd as dao.database
dim rst as dao.recordset
dim str as string

str = "SELECT userId,uname FROM USER"

set rd=currentdb()
set rst=rd.openrecordset(User)

If rst.RecordCount > 0 Then

With Me.combox1
.RowSourceType="Table/query"
.RowSource=str
//From Here, How do I show only the user name and not
the user ID ??


Make sure the combo box's column count property is set to 2.
Then set the ColumnWidths property to 0;
the 0 width column will not be displayed in the drop down
list and the second column will be the one displayed in th
combo's text area.
 
Thanks
-----Original Message-----



Make sure the combo box's column count property is set to 2.
Then set the ColumnWidths property to 0;
the 0 width column will not be displayed in the drop down
list and the second column will be the one displayed in th
combo's text area.
 
Back
Top