For Programmers: Free Programming Magazines  


Home > Archive > Visual Basic Syntax > April 2005 > Help with Combo boxes









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Help with Combo boxes
Ricky

2005-04-21, 8:59 pm

Hi everybody,

Here is the situation. I have a combo box in my application called
cboInfoRegion, which is supposed to get the name of the state/province for
the current customer from an access database table. For some reason, I can
not get the combo box to automatically show the name of the region once the
application is run. All other fields on this form get successfully populated
with the correct data but the combo box. I tried using this loop but it
didn't work.

Dim i as Integer

Set cboInfoRegion.DataSource = PointsRecs

For i = 0 to cboInfoRegion.ListCount
if cboInfoRegion.Text = !REGION then
cboInfoRegion.ListIndex = i
end if
Next i


Is there anything I'm doing wrong in that piece of code? It wouldn't
surprise me if the error is obvious as I'm still a newbie. =)
Thanks

P.S. Style property of this combo box is set to: 2 - Dropdown List
Ken Halter

2005-04-21, 8:59 pm

"Ricky" <Ricky@discussions.microsoft.com> wrote in message
news:B7DA2265-4FD8-4A7F-B66D-5A2FE8A26CB6@microsoft.com...
>
> Dim i as Integer
>
> Set cboInfoRegion.DataSource = PointsRecs
>
> For i = 0 to cboInfoRegion.ListCount

Debug.Print cboInfoRegion.Text, "What the heck's the bang character
for?"
> if cboInfoRegion.Text = !REGION then
> cboInfoRegion.ListIndex = i
> end if
> Next i
>


Sprinkle Debug.Prints around, or even MsgBox's that show info. Delete or
comment them out when done. fwiw, the line that does the comparison doesn't
look valid.

--
Ken Halter - MS-MVP-VB - http://www.vbsight.com
Sign up now to help keep VB support alive - http://classicvb.org/petition
Please keep all discussions in the groups..


Daryl Muellenberg

2005-04-25, 8:59 pm

The line:

if cboInfoRegion.Text = !REGION then

should be:

if cboInfoRegion.List(i) = !REGION then

Daryl

"Ricky" <Ricky@discussions.microsoft.com> wrote in message
news:B7DA2265-4FD8-4A7F-B66D-5A2FE8A26CB6@microsoft.com...
> Hi everybody,
>
> Here is the situation. I have a combo box in my application called
> cboInfoRegion, which is supposed to get the name of the state/province for
> the current customer from an access database table. For some reason, I can
> not get the combo box to automatically show the name of the region once

the
> application is run. All other fields on this form get successfully

populated
> with the correct data but the combo box. I tried using this loop but it
> didn't work.
>
> Dim i as Integer
>
> Set cboInfoRegion.DataSource = PointsRecs
>
> For i = 0 to cboInfoRegion.ListCount
> if cboInfoRegion.Text = !REGION then
> cboInfoRegion.ListIndex = i
> end if
> Next i
>
>
> Is there anything I'm doing wrong in that piece of code? It wouldn't
> surprise me if the error is obvious as I'm still a newbie. =)
> Thanks
>
> P.S. Style property of this combo box is set to: 2 - Dropdown List



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com