A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Making combo box display first entry in list



 
 
Thread Tools Display Modes
  #1  
Old December 20th, 2006, 05:48 PM posted to microsoft.public.access.forms
Steven Sutton
external usenet poster
 
Posts: 29
Default 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  
Old December 20th, 2006, 06:51 PM posted to microsoft.public.access.forms
Daniel
external usenet poster
 
Posts: 1,017
Default 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  
Old December 20th, 2006, 10:49 PM posted to microsoft.public.access.forms
Steven Sutton
external usenet poster
 
Posts: 29
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 11:22 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.