index / seek question 
Author Message
 index / seek question

Hi there,

In my app I am filling a combo box with a field from an access table.

The code is:

For i = 1 To ClientTable.RecordCount
    If ClientTable![Company Name] <> "" Then
    ComboSearchData.AddItem ClientTable![Company Name]
    End If
    ClientTable.MoveNext
Next i

The problem is that if there are more than one company with the same name,
when you select either one it always seeks the first record with that name.

Could anyone help me with this?

Thank you!!!

Dan

--
Data-Pro Consulting, Inc.
Dan Perlman


Phone 801-495-0100 Fax 801-495-0200
Web http://www.*-*-*.com/
Phone 801-495-0100 Fax 801-495-0200

--
Data-Pro Consulting, Inc.
Dan Perlman - President / CEO


Phone 801-495-0100 Fax 801-495-0200
Web http://www.*-*-*.com/
Phone 801-495-0100 Fax 801-495-0200



Thu, 18 Dec 2003 03:27:24 GMT  
 index / seek question
I suggest you use a recordset created by a query to populate the combobox.
ex.
Private Sub Whatever()
dim rs as New ADODB.RecordSet
dim sqlRs as string
sqlRs = "SELECT DISTINCT [Company Name] FROM ClientTable" _
        & " WHERE fieldName = " & whatever
rs.Open sqlRs,yourConnection,,adCmdText
rs.MoveFirst
Do Until rs.EOF
  ComboBoxName.AddItem rs![Company Name]
  rs.MoveNext
Loop
rs.Close
Set rs = Nothing
End Sub

Quote:

> Hi there,

> In my app I am filling a combo box with a field from an access table.

> The code is:

> For i = 1 To ClientTable.RecordCount
>     If ClientTable![Company Name] <> "" Then
>     ComboSearchData.AddItem ClientTable![Company Name]
>     End If
>     ClientTable.MoveNext
> Next i

> The problem is that if there are more than one company with the same
name,
> when you select either one it always seeks the first record with that
name.

> Could anyone help me with this?

> Thank you!!!

> Dan

> --
> Data-Pro Consulting, Inc.
> Dan Perlman


> Phone 801-495-0100 Fax 801-495-0200
> Web http://www.dataproconsult.com
> Phone 801-495-0100 Fax 801-495-0200

> --
> Data-Pro Consulting, Inc.
> Dan Perlman - President / CEO


> Phone 801-495-0100 Fax 801-495-0200
> Web http://www.dataproconsult.com
> Phone 801-495-0100 Fax 801-495-0200

--
Posted via CNET Help.com
http://www.help.com/


Thu, 18 Dec 2003 10:30:06 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. SQL / .Index / .Seek Question

2. 2 questions: Code doesn't work when I split database and Seek/Index question

3. using .index and .seek function

4. Problems with the methods Index and Seek

5. How to set controlling index before doing SEEK in Access Basic

6. Multiple Index Seek (Acc97)

7. sequential file, line indexing, seeking and readline

8. ADO Index property and Seek method

9. Index Property/SEEK method Problem with ADO

10. Seek, Index on ADO Recordset

11. Seek - Index. ADO 2.1

12. Using SEEK wih multiple-field indexes

 

 
Powered by phpBB® Forum Software