Results 1 to 3 of 3

Thread: My combo box is bigger then Phantom Menace

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 1999
    Posts
    89

    Post

    Hi all,

    I have a multiple combo boxes on my form accessing a SQL Server 7.0 database using ADO. I also have the far point spread control that is accessing the data.

    This is the code i am using to additems to the combo box


    'do the sql statement

    SQLStmt = "Select distinct db_name from " & DatabaseName
    SQLStmt = gSQLStmt & "database"
    RetrieveADO gSQLStmt

    'go to the retrieve ado fucntion
    'get information back from the server

    Do Until RetrieveADO.EOF

    combobox1.AddItem RetrieveADORecordset![db_name]
    RetrieveADORecordset.MoveNext
    Loop

    RetrieveADORecordset.Close

    I am calling this procedure from the spread click event. The problem is that every time i click the spread it is running through the proceducre. What i want to do is have some code that would read the items in the combo box and if there are items in there, the procedure would stop. I thought about using the clear method to clear out the combo box but i thought this would be ineffeicent because the combobox would still make a trip to the SQL server.

    I want to impress my boss, so any help is aprreciated

    Thanks
    Scott

  2. #2
    Lively Member
    Join Date
    Jan 1999
    Posts
    82

    Post

    Hi,

    As the first line of your statement try:

    if combobox.listcount > 0 then exit sub

    listcount is the number of items in the combobox

    HTH,

    Preeti

  3. #3

    Thread Starter
    Lively Member
    Join Date
    May 1999
    Posts
    89

    Post

    Thanks that did the trick I added this line to my code


    If combo.ListCount <= 0 Then

    go retrive values,

    end if

    I have this on about 5 combo boxes so i didnt want to exit out of the sub.

    Thanks again

    Scott

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width