Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

function to populate combobox

Status
Not open for further replies.

KatherineF

Technical User
Mar 3, 2003
124
US
I am wondering what will be a good way to change the function to populate combobox (add a default value to be selected). The function I have now is used a lot within an application. Since VBScript does not support optional arguments to be passed to a function I don't want to break a lot of pages. So there are 2 functions in my library that have been used for populating a combobox: ComboEdit and ComboEditRS

Function ComboEdit(cCboSql, cName, oFld, oUpdRes, iID)
Dim oRS

On Error Resume Next

' Open a connection
OpenConn oConn
oResult = TableOpen(oConn, oRS, cCboSql, lib_ReadOnlyData)

' Detect and process error
If IsGoodStr(oResult) Then
ErrorDisplay oResult & " (" & oFld.Name & ")"
End If

' Open a combo by RS
ComboEditRS oRS, 0, 1, cName, oFld, oUpdRes, iID
End Function

ComboEditRS Function handles the html part.

I need to pass extra parameter - defaultvalue to be selected - to both of these functions. What is the right way to do this? Thank you!

 
Or modify them so that they require the default value, but you'd pass a "" for none. But of course that would break everything. :) I think you'll just need a new one, like Chris says.

A clunky way (better to add a new function, faster, anyway, due to no string manipulation) would be to add something unique to the default value before sending it to the function. Like say adding "|||D" to the end of whichever value is supposed to be the default, and then clipping that off any item that contains it and make that one the default, and if no value has the unique string then there's no default.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top