Add value to comb box

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.
 
G

Guest

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
 
J

James B

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.
 
M

Marshall Barton

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.
 
J

James B.

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top