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

Easy combo box question

P: n/a
I have another question for the community, and hopefully it's an easy
one. It seems ridiculously simple, but I can't find anything on it.

I have a combo box that is bound to a table. When a form is opened, I'd
like the current value of said combo box to be dictated by a value given
by the previous form. For the life of me, I can't figure out how to use
code to set the current value of a combo box. Here is the simple code,
taken right from a book, that I'm trying to work with.

Dim i As Integer

With Me!cboCustomer
For i = 0 To .ListCount - 1
If .Column(3, i) = Me!tboCustomerNumber Then
.Selected(i) = True <----------------------------------
Exit For
End If
Next i
End With

The line with the arrow pointing to it is where it breaks down, as the
code was written for a list box. A combo box has no .Selected property,
and I can't find anything that is its equivalent.

Any help would be greatly appreciated.

Mason

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Try a global constant possibly CustNo as Long. This must be declared in an
indipendent Module (ie one not bound to a form.
Assuming the bound column in the Combo box is bound to tboCustomerNumber,
then OnClose of the previous form set CustNo = tboCustomerNumber and OnOpen
of the new form set Me!ComboBox = CustNo.

Phil

"Mason Wood" <ma***@codemonkey.cc> wrote in message
news:3f*********************@news.frii.net...
I have another question for the community, and hopefully it's an easy
one. It seems ridiculously simple, but I can't find anything on it.

I have a combo box that is bound to a table. When a form is opened, I'd
like the current value of said combo box to be dictated by a value given
by the previous form. For the life of me, I can't figure out how to use
code to set the current value of a combo box. Here is the simple code,
taken right from a book, that I'm trying to work with.

Dim i As Integer

With Me!cboCustomer
For i = 0 To .ListCount - 1
If .Column(3, i) = Me!tboCustomerNumber Then
.Selected(i) = True <----------------------------------
Exit For
End If
Next i
End With

The line with the arrow pointing to it is where it breaks down, as the
code was written for a list box. A combo box has no .Selected property,
and I can't find anything that is its equivalent.

Any help would be greatly appreciated.

Mason

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 12 '05 #2

P: n/a


Thanks for the response, Phil. Worked great!

Mason

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.