By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,490 Members | 1,280 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,490 IT Pros & Developers. It's quick & easy.

Combo Box inital value to display

P: n/a
I have a combo box that displays the names of all the users in my "Users"
table. I set the RowSource to a Query from the "User" and "Project" tables.

I can select any name from the list and that name comes up in the combo box
on the form. Everything works fine this way I just want to automatically
put the user name in the combo box display.

Is there a way to automate displaying a name in the combo box without having
to use the drop down.

I get the current users ID number by using an API call (thanks to Ken Getz).

After the call returns the ID I take that value and place it in a hidden
textbox on my main form.

????? How do I get the name from the "User" table that matches this ID to
displayed in the combo box? The combo box is already populated with names.
?????

I tried using the RowSource property with a select statement but that only
limited the list to the user name that matched the ID. It did not display
it in the combo box though, you still had to select it. I figured that was
because the RowSource property only puts data in the rows and does not do
the displaying of the data.

I do not want to lose the list of users, I just want to display the logged
in one.

I use the ID to filter the records in a list box on the form and other
things.

Thanks.

Dave N
Nov 12 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"Dave N" <ne*********@johndeere.com> wrote in message
news:3f********@news1.dpn.deere.com...
I have a combo box that displays the names of all the users in my "Users"
table. I set the RowSource to a Query from the "User" and "Project" tables.
I can select any name from the list and that name comes up in the combo box on the form. Everything works fine this way I just want to automatically
put the user name in the combo box display.

Is there a way to automate displaying a name in the combo box without having to use the drop down.

I get the current users ID number by using an API call (thanks to Ken Getz).
After the call returns the ID I take that value and place it in a hidden
textbox on my main form.

????? How do I get the name from the "User" table that matches this ID to displayed in the combo box? The combo box is already populated with names. ?????

I tried using the RowSource property with a select statement but that only
limited the list to the user name that matched the ID. It did not display
it in the combo box though, you still had to select it. I figured that was because the RowSource property only puts data in the rows and does not do
the displaying of the data.

I do not want to lose the list of users, I just want to display the logged
in one.

I use the ID to filter the records in a list box on the form and other
things.

Thanks.

Dave N


Try setting the Default value. Use the Dlookup function to convert the ID to
Username.
Fred Zuckerman
San Diego, CA, USA
Nov 12 '05 #2

P: n/a
"Dave N" <ne*********@johndeere.com> wrote in message
news:3f********@news1.dpn.deere.com...
I have a combo box that displays the names of all the users in my "Users"
table. I set the RowSource to a Query from the "User" and "Project" tables.
I can select any name from the list and that name comes up in the combo box on the form. Everything works fine this way I just want to automatically
put the user name in the combo box display.

Is there a way to automate displaying a name in the combo box without having to use the drop down.

I get the current users ID number by using an API call (thanks to Ken Getz).
After the call returns the ID I take that value and place it in a hidden
textbox on my main form.

????? How do I get the name from the "User" table that matches this ID to displayed in the combo box? The combo box is already populated with names. ?????

I tried using the RowSource property with a select statement but that only
limited the list to the user name that matched the ID. It did not display
it in the combo box though, you still had to select it. I figured that was because the RowSource property only puts data in the rows and does not do
the displaying of the data.

I do not want to lose the list of users, I just want to display the logged
in one.

I use the ID to filter the records in a list box on the form and other
things.

Thanks.

Dave N


You can do this a few different ways:

#1 - If your combo box Row Source query has both ID and Username (i.e
Select ID, Name From Users) and the ID is hidden, you can simply assign the
User ID to the combo box.

Ex.

Sub Form_OnCurrent()
Combobox1 = HiddenIDControl
End Sub

#2 - If you ONLY want to show the user who is currently logged on, you can
also alter your rowsource query a little

"Select [ID], [Name] From [UsersTable] Where [ID]=" &
Forms![YourFormName]![YouHiddenControlName]

Hope that helps...
Nov 12 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.