-
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
-
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
-
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