If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Making combo box display first entry in list
I am using two combo boxes to enter data into a table. The contents of the
second combo box list will change depending on the entry in the first combo box. I have all of that working just fine. When I select something in the first combo box, the second boxes contents get cleared and then I requery the second box to get the new list. The problem I can't figure out is how to get the second box to always show the first item in its list (after the its list has been updated, of course). Here's some more specific details in case it helps. There is a table (tblNamesAndVersions) that has three fields - JobName, Version, VersionIndex. Combo box 1 uses a query to get the distinct job names from the table. The second combo box then uses a query based on the first combo boxes contents to pull the Versions that are relevant to the JobName selected in combo #1. As I said, all of this is working just fine. All I am wanting to do now is to make the contents of the second combo box be the first entry in it list. Can anyone tell me how to do this? Thanks in advance. |
#2
|
|||
|
|||
Making combo box display first entry in list
Steven,
Me.cboName = Me.cboName.ItemData(0) obviously chnge cboName with the name of your combo box. by changing the value in parenthesis you can control which item in your list is displayed. Daniel "Steven Sutton" wrote: I am using two combo boxes to enter data into a table. The contents of the second combo box list will change depending on the entry in the first combo box. I have all of that working just fine. When I select something in the first combo box, the second boxes contents get cleared and then I requery the second box to get the new list. The problem I can't figure out is how to get the second box to always show the first item in its list (after the its list has been updated, of course). Here's some more specific details in case it helps. There is a table (tblNamesAndVersions) that has three fields - JobName, Version, VersionIndex. Combo box 1 uses a query to get the distinct job names from the table. The second combo box then uses a query based on the first combo boxes contents to pull the Versions that are relevant to the JobName selected in combo #1. As I said, all of this is working just fine. All I am wanting to do now is to make the contents of the second combo box be the first entry in it list. Can anyone tell me how to do this? Thanks in advance. |
#3
|
|||
|
|||
Making combo box display first entry in list
Thanks for the code Daniel. And, (as I am sure you won't be surprised to find
out) it works...unless. If the first value in the second combo list is a Null or Zero Length string it doesn't pop in. It is sort of the reason I got into this dilema in the first place. I was trying to run an SQL statement using the Name (from the first combo box) and the Version (from the second combo box) to get the Index. But the SQL wouldn't match the Null from the combo box to the Null in the Table's field. Plus I was having issues connecting to the database via VB. Anyway, thanks for the assistance and if you have any further suggestions, I would love to hear them. "Daniel" wrote: Steven, Me.cboName = Me.cboName.ItemData(0) obviously chnge cboName with the name of your combo box. by changing the value in parenthesis you can control which item in your list is displayed. Daniel "Steven Sutton" wrote: I am using two combo boxes to enter data into a table. The contents of the second combo box list will change depending on the entry in the first combo box. I have all of that working just fine. When I select something in the first combo box, the second boxes contents get cleared and then I requery the second box to get the new list. The problem I can't figure out is how to get the second box to always show the first item in its list (after the its list has been updated, of course). Here's some more specific details in case it helps. There is a table (tblNamesAndVersions) that has three fields - JobName, Version, VersionIndex. Combo box 1 uses a query to get the distinct job names from the table. The second combo box then uses a query based on the first combo boxes contents to pull the Versions that are relevant to the JobName selected in combo #1. As I said, all of this is working just fine. All I am wanting to do now is to make the contents of the second combo box be the first entry in it list. Can anyone tell me how to do this? Thanks in advance. |
Thread Tools | |
Display Modes | |
|
|