Combo box Index problem

Combo box Index problem

Post by Peter Hardinge » Sat, 03 Aug 2002 08:11:43



Hi,
I have a H/PC 2000 and the data comes from a pocket Access file.
Could somebody please tell me why the index of my combo box doesn't match
the primary key of EntryID and creates a new index starting at 0.
I have similar code working on other combo boxes on the main form that seems
to work fine. The combo box is on a frame, would that make a difference?
My code is as follows:

    ' Fill in combo box for Staff Names
    Set oRecordset = CreateObject("ADOCE.Recordset.3.1")
    oRecordset.Source = "SELECT EntryID, Name FROM tblStaff ORDER BY Name;"
    oRecordset.CursorType = adOpenForwardOnly
    oRecordset.ActiveConnection = oConnection
    oRecordset.Open
    Do While Not oRecordset.EOF
        cboStaff.AddItem oRecordset.Fields("Name")
        cboStaff.ItemData(cboStaff.NewIndex) = oRecordset.Fields("EntryID")
        oRecordset.MoveNext
    Loop
    oRecordset.Close
    Set oRecordset = Nothing

 Please let me know the solution to the problem or any possible reason for
it not to work.

Thank You

Peter

 
 
 

1. List Index is out of Bounds - Combo box problems

I need to load a combo box with a field from a table, I found some
code on-line but keep getting the List Index is out of bounds error. I
am new with Delphi but have some experience with VB. I am lost and
need to get moving on this. Please help me!!! Here is the code:

qry.close;
qry.sql.Clear;

qry.SQL.add('Select field FROM table');

try
 qry.prepared;
 qry.open;
except
 exit;
end;
try
 count := qry.recordCount;
except
 exit;
end;

combobox.Items.Clear;
for loopCount := 0 to pred(Count) do
begin
 combobox[loopCount] := dmrItemReports.qryReport.fields[0].asString;
 qry.Next
end;

qry.close;

Any ideas???????

2. Help in deciphering this query to create a calendar table for 100 years

3. Populating a combo box from another combo box

4. from com to keyboard

5. Populate a combo box from another combo box selection

6. Universe DBA positions in Dallas, TX

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

8. How to select only if multiple rows meet criteria?

9. Problems making a automatic text box when selecting in a combo box

10. Vb 4.0 Problems updating Text Boxes from Combo Box linked to Data Control

11. Indexing for Combo Boxes

12. COMBO BOX INDEX PROPERTY

13. how add columns to a combo box in vb like access combos