COMBO BOX INDEX PROPERTY

COMBO BOX INDEX PROPERTY

Post by Monstermas » Wed, 02 Feb 2000 04:00:00



I have an Access database that has a table with two fields, one is an
AutoNumber and the other the "Name".  I am trying to load each record in the
table into a ComboBox.  I can successfully get the "Name" field loaded,
however for later use, I need to be able to pass the AutoNumber field as the
index with the following code:

While Not datDistricts.Recordset.EOF
    cboDistrict.AddItem (datDistricts.Recordset.Fields("Name").Value, _
                datDistricts.Recordset.Fields("DistrictID").Value)
    datDistricts.Recordset.MoveNext
Wend

This yields an "Expected =" msgbox.  When I change it to:
While Not datDistricts.Recordset.EOF
    cboDistrict.AddItem = (datDistricts.Recordset.Fields("Name").Value, _
                datDistricts.Recordset.Fields("DistrictID").Value)
    datDistricts.Recordset.MoveNext
Wend

This yeilds an "Expected )" msgbox.  After quite a frustrating time with
placement of the ")" character, I end up with an "Expected End of Statement"
msgbox.

Does anyone have an idea what I can do?  I have multilple tables in the
database and the AutoNumber field is a reference to the "Name" value of this
table.  I will be storing just the AutoNumber field in various other tables
in the database.

 
 
 

COMBO BOX INDEX PROPERTY

Post by Jim in Clevelan » Wed, 02 Feb 2000 04:00:00



> I have an Access database that has a table with two fields, one is an
> AutoNumber and the other the "Name".  I am trying to load each record in the
> table into a ComboBox.  I can successfully get the "Name" field loaded,
> however for later use, I need to be able to pass the AutoNumber field as the
> index with the following code:

> While Not datDistricts.Recordset.EOF
>     cboDistrict.AddItem (datDistricts.Recordset.Fields("Name").Value, _
>                 datDistricts.Recordset.Fields("DistrictID").Value)
>     datDistricts.Recordset.MoveNext
> Wend

<snip>

The comma between the two feild values doesn't look like a good way to
concatenate to me.  How about appending a blank space between 'em?  See
what happens if you try:

 While Not datDistricts.Recordset.EOF
     cboDistrict.AddItem (datDistricts.Recordset.Fields("Name").Value  _
                 & " " &
datDistricts.Recordset.Fields("DistrictID").Value)
     datDistricts.Recordset.MoveNext
 Wend

If this is helpful, please do not take it as an endor*t of you using
autonumbers.
--
Jim in Cleveland
If you're writing to me, in my address
change "REAL_Address.see.below" to "worldnet.att.net"

"What's so funny 'bout peace, love & understanding?"
     - Nick Lowe

 
 
 

COMBO BOX INDEX PROPERTY

Post by George Sempl » Wed, 02 Feb 2000 04:00:00


It looks like he is trying to force an index value for the combo items. He
would be better adviced to utilize the ItemData property to hold the record
ID value.




> > I have an Access database that has a table with two fields, one is an
> > AutoNumber and the other the "Name".  I am trying to load each record in
the
> > table into a ComboBox.  I can successfully get the "Name" field loaded,
> > however for later use, I need to be able to pass the AutoNumber field as
the
> > index with the following code:

> > While Not datDistricts.Recordset.EOF
> >     cboDistrict.AddItem (datDistricts.Recordset.Fields("Name").Value, _
> >                 datDistricts.Recordset.Fields("DistrictID").Value)
> >     datDistricts.Recordset.MoveNext
> > Wend
> <snip>

> The comma between the two feild values doesn't look like a good way to
> concatenate to me.  How about appending a blank space between 'em?  See
> what happens if you try:

>  While Not datDistricts.Recordset.EOF
>      cboDistrict.AddItem (datDistricts.Recordset.Fields("Name").Value  _
>                  & " " &
> datDistricts.Recordset.Fields("DistrictID").Value)
>      datDistricts.Recordset.MoveNext
>  Wend

> If this is helpful, please do not take it as an endor*t of you using
> autonumbers.
> --
> Jim in Cleveland
> If you're writing to me, in my address
> change "REAL_Address.see.below" to "worldnet.att.net"

> "What's so funny 'bout peace, love & understanding?"
>      - Nick Lowe

 
 
 

COMBO BOX INDEX PROPERTY

Post by Monstermas » Sat, 05 Feb 2000 04:00:00


Thanks for the suggestion, however, when I try to set the ItemData property
via code, I get an "Invalid use of property" error.

According to MSDN and the pop-up help of the AddItem method, the syntax is
as follows:
    ComboBox.AddItem (Item as String, [Index])

So, back to the original question, in VB6 you can set the index property of
an item that you add to a ComboBox (which must be in integer value), when
trying to do so from a database, I am unable to do so.  Any other
suggestions.  Am I missing something (for example, you can only use a value
and not a named value?)


>It looks like he is trying to force an index value for the combo items. He
>would be better adviced to utilize the ItemData property to hold the record
>ID value.




>> > I have an Access database that has a table with two fields, one is an
>> > AutoNumber and the other the "Name".  I am trying to load each record
in
>the
>> > table into a ComboBox.  I can successfully get the "Name" field loaded,
>> > however for later use, I need to be able to pass the AutoNumber field
as
>the
>> > index with the following code:

>> > While Not datDistricts.Recordset.EOF
>> >     cboDistrict.AddItem (datDistricts.Recordset.Fields("Name").Value, _
>> >                 datDistricts.Recordset.Fields("DistrictID").Value)
>> >     datDistricts.Recordset.MoveNext
>> > Wend
>> <snip>

>> The comma between the two feild values doesn't look like a good way to
>> concatenate to me.  How about appending a blank space between 'em?  See
>> what happens if you try:

>>  While Not datDistricts.Recordset.EOF
>>      cboDistrict.AddItem (datDistricts.Recordset.Fields("Name").Value  _
>>                  & " " &
>> datDistricts.Recordset.Fields("DistrictID").Value)
>>      datDistricts.Recordset.MoveNext
>>  Wend

>> If this is helpful, please do not take it as an endor*t of you using
>> autonumbers.
>> --
>> Jim in Cleveland
>> If you're writing to me, in my address
>> change "REAL_Address.see.below" to "worldnet.att.net"

>> "What's so funny 'bout peace, love & understanding?"
>>      - Nick Lowe

 
 
 

COMBO BOX INDEX PROPERTY

Post by Bob Butle » Sun, 06 Feb 2000 04:00:00




Quote:> Thanks for the suggestion, however, when I try to set the ItemData
property
> via code, I get an "Invalid use of property" error.

> According to MSDN and the pop-up help of the AddItem method, the
syntax is
> as follows:
>     ComboBox.AddItem (Item as String, [Index])

<cut>
The syntax should be:
    combobox.additem stringvalue,index
or:
    Call combobox.additem(stringvalue,index)
with ",index" being optional in both cases
The help ofte shows parentheses around argument lists but that is only
valid if the CALL keyword is used

--
Please reply via the newsgroup only

Sent via Deja.com http://www.deja.com/
Before you buy.

 
 
 

COMBO BOX INDEX PROPERTY

Post by Monstermas » Tue, 08 Feb 2000 04:00:00


Thanks for the help.  However, now I receive a Runtime Error "5", Invalid
procedure call or argument, when I modify as follows:

While Not datDistricts.Recordset.EOF
    Call cboDistrict.AddItem((datDistricts.Recordset.Fields("Name").Value),
(datDistricts.Recordset.Fields("DistrictID").Value))
    datDistricts.Recordset.MoveNext
Wend




>> Thanks for the suggestion, however, when I try to set the ItemData
>property
>> via code, I get an "Invalid use of property" error.

>> According to MSDN and the pop-up help of the AddItem method, the
>syntax is
>> as follows:
>>     ComboBox.AddItem (Item as String, [Index])

><cut>
>The syntax should be:
>    combobox.additem stringvalue,index
>or:
>    Call combobox.additem(stringvalue,index)
>with ",index" being optional in both cases
>The help ofte shows parentheses around argument lists but that is only
>valid if the CALL keyword is used

>--
>Please reply via the newsgroup only

>Sent via Deja.com http://www.deja.com/
>Before you buy.

 
 
 

COMBO BOX INDEX PROPERTY

Post by Glenn Miyashi » Tue, 08 Feb 2000 04:00:00


Remove the comma


>Thanks for the help.  However, now I receive a Runtime Error "5", Invalid
>procedure call or argument, when I modify as follows:

>While Not datDistricts.Recordset.EOF
>    Call cboDistrict.AddItem((datDistricts.Recordset.Fields("Name").Value),
>(datDistricts.Recordset.Fields("DistrictID").Value))
>    datDistricts.Recordset.MoveNext
>Wend




>>> Thanks for the suggestion, however, when I try to set the ItemData
>>property
>>> via code, I get an "Invalid use of property" error.

>>> According to MSDN and the pop-up help of the AddItem method, the
>>syntax is
>>> as follows:
>>>     ComboBox.AddItem (Item as String, [Index])

>><cut>
>>The syntax should be:
>>    combobox.additem stringvalue,index
>>or:
>>    Call combobox.additem(stringvalue,index)
>>with ",index" being optional in both cases
>>The help ofte shows parentheses around argument lists but that is only
>>valid if the CALL keyword is used

>>--
>>Please reply via the newsgroup only

>>Sent via Deja.com http://www.deja.com/
>>Before you buy.

VB IRC for Intermediate to Advanced Users.
   Undernet   #vb-advanced
 
 
 

COMBO BOX INDEX PROPERTY

Post by Monstermas » Wed, 09 Feb 2000 04:00:00


Removing the comma returns me to the beginning of my problem, endless errors
attempting to set the index value.  Expected ")", Expected list seperator,
Expected End of Statement.

Anyone have an idea how I can accomplish the following.  Maybe my original
algorithim is flawed.

With an Access db and multiple tables containing relational data, I desire
to update one table (Called [Recruiter Information]) with data in the
[District Information] table.  Namely, I would prefer to save [District
Information].DistrictID into [Recruiter Information].DistrictID and maintain
referential integrity.  I would like to make available to my users a list of
the [District Information].Name field to choose from and to prevent the
accidental input of a value not in my [District Information].Name field.

If anyone has a suggestion I would greatly appreciate it.  I've been stumped
in the section (which will actually apply to 1 more major input form later
on) for over three weeks.    Thanks in advance.


>Remove the comma


>>Thanks for the help.  However, now I receive a Runtime Error "5", Invalid
>>procedure call or argument, when I modify as follows:

>>While Not datDistricts.Recordset.EOF
>>    Call

cboDistrict.AddItem((datDistricts.Recordset.Fields("Name").Value),
>>(datDistricts.Recordset.Fields("DistrictID").Value))
>>    datDistricts.Recordset.MoveNext
>>Wend




>>>> Thanks for the suggestion, however, when I try to set the ItemData
>>>property
>>>> via code, I get an "Invalid use of property" error.

>>>> According to MSDN and the pop-up help of the AddItem method, the
>>>syntax is
>>>> as follows:
>>>>     ComboBox.AddItem (Item as String, [Index])

>>><cut>
>>>The syntax should be:
>>>    combobox.additem stringvalue,index
>>>or:
>>>    Call combobox.additem(stringvalue,index)
>>>with ",index" being optional in both cases
>>>The help ofte shows parentheses around argument lists but that is only
>>>valid if the CALL keyword is used

>>>--
>>>Please reply via the newsgroup only

>>>Sent via Deja.com http://www.deja.com/
>>>Before you buy.

>VB IRC for Intermediate to Advanced Users.
>   Undernet   #vb-advanced

 
 
 

1. Populating a combo box from another combo box

Hello,
    I'm a relatively new programmer and I'm trying to figure out how to use
my selection in a ComboBox1 lead to filling my second combo box. I am doing
this in VB code from an Access 2000 data base. The Database has two tables
and after selecting combobox1 from my choice in the first table I want my
second combo box to fill with the selections on table two that correlate
with my table one selection. Thanks for your time and some sample code would
help.

Chas

2. How to save/restore table(s)

3. Populate a combo box from another combo box selection

4. Q: How to delete Repository Metadata

5. selecting records for 2nd combo box dependant on first combo box

6. RAID stride size (stripe) and Oracle block size

7. Datachanged property on combo box!

8. Remote Data Control Problem

9. Setting Combo Box Style Property At Runtime??

10. Referring to property within select statement in list/combo box rowsource

11. Indexing for Combo Boxes

12. Combo box Index problem