Connecting Tech Pros Worldwide Help | Site Map

Easy combo box question

Mason Wood
Guest
 
Posts: n/a
#1: Nov 12 '05
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!
Phil Stanton
Guest
 
Posts: n/a
#2: Nov 12 '05

re: Easy combo box question


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" <mason@codemonkey.cc> wrote in message
news:3f9d9a59$0$195$75868355@news.frii.net...[color=blue]
> 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![/color]


Mason Wood
Guest
 
Posts: n/a
#3: Nov 12 '05

re: Easy combo box question




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!
Closed Thread


Similar Microsoft Access / VBA bytes