Click to See Complete Forum and Search --> : Problem populating drop down list!!


tirion_angel
08-14-2006, 09:51 AM
Hello!

I'm having problems populating my drop down list.
Here is my code:

FUNCTION Get_Version
Dim ls_sql, ls_version
Dim ls_result

ls_result = " "

ls_sql = "SELECT DISTINCT version "
ls_sql = ls_sql & "FROM issues "
ls_sql = ls_sql & "WHERE project_id = 10 "
ls_sql = ls_sql & "AND status_id = 5 "
ls_sql = ls_sql & "ORDER BY version "

Set gobjRecordset = gobjConnection.Execute(ls_sql)
Do Until gobjRecordset.EOF
ls_version = gobjRecordset.Fields("version")

ls_result = ls_result & "<option value=" & ls_version & ">" & ls_version & "</option>" & VBCRLF
gobjRecordset.MoveNext
Loop
Get_Version = TRIM(ls_result)
END FUNCTION


The problem is, some of the fields come back blank, and I need to remove those from the options in the drop down list. So far, I haven't been able to get it to work. Any ideas?

ahk2chan
08-14-2006, 10:10 AM
In your query, instead of

ls_sql = "SELECT DISTINCT version "
ls_sql = ls_sql & "FROM issues "
ls_sql = ls_sql & "WHERE project_id = 10 "
ls_sql = ls_sql & "AND status_id = 5 "
ls_sql = ls_sql & "ORDER BY version "


add to bold line:


ls_sql = "SELECT DISTINCT version "
ls_sql = ls_sql & "FROM issues "
ls_sql = ls_sql & "WHERE project_id = 10 "
ls_sql = ls_sql & "AND status_id = 5 "
ls_sql = ls_sql & " and version is not null and version <> ''"
ls_sql = ls_sql & "ORDER BY version "


Then no version that is null or empty string will be selected out by your query.

tirion_angel
08-14-2006, 10:16 AM
Awesome! That worked great! I had tried something similar, but had the syntax wrong. Thanks for your help!!