Type mismatch while displaying a return function in a combobox

Here is my code.

Sub Click(Source As Button)

Dim ws As New NotesUIWorkspace

Dim ui As NotesUIDocument

Set ui = ws.CurrentDocument

Dim var As Variant

var = RetrieveCP()

i=0

Forall n In var

Call ui.FieldSetText(“CP”, var(i))

i = i + 1

End Forall

End Sub


Function RetrieveCP () As Variant

Dim conn As New ODBCConnection

Dim query As New ODBCQuery

Dim result As New ODBCResultSet

Dim i As Integer

Dim cpList(0 To 10) As String

query.SQL = “select xname from axtdir_documents where xdirectorydocumenttype = 3”

Messagebox “connect to faxcore server”

If Not conn.ConnectTo(“faxcore”, “sa”, “dba”) Then

Messagebox (“Fail to connect to Faxcore database. Please contact Faxcore support.”)

Exit Function

Else

Set query.Connection = conn

Set result.Query = query

result.Execute

If Not result.IsResultSetAvailable Then

Messagebox ("Could not retrieve result from the database/Result unavailable.")

Exit Function

Else

i = 0

Do

result.nextrow

cp = result.GetValue("xName", cp

cpList(i) = cp

i = i + 1

Loop Until result.IsEndOfData		

End If

End If

result.Close

conn.Disconnect

RetrieveCP = cpList

End Function


basically wht the above code does is to retrieve a list of data from a sqlserver and populate the data to a combobox.

the funtion return a variant data type by default(that how it handdle the array) when it was called. however the combobox refuse to display the data i pulled and feed to the array bcoz the data type is variant instead of string. Cstr wont do the trick.

I tried using FieldAppendText but it gives me this error msg; Nots Error: Appending text to a non-dialog list keyword field is not allowed.

The reason i do it this was because i need to run this as an agent on a server instead of a client and populate to the combobox so that the user can see a list of option for them.

Is there any other way to populate the combobox as it only take string and not variant as a whole.

Subject: Type mismatch while displaying a return function in a combobox

Try adding it to the backend document via should automatically refresh frontend if not switched off.

Dim doc As Notesdocument

Set doc = ui.Document

Call doc.replaceitemvalue(“yourfield”,RetrieveCP )

Subject: RE: Type mismatch while displaying a return function in a combobox

isnt that backend wont be able to control UI process?

the code u mention should be places in the front end instead of backend. i will try it first thing later.

thanks anyway.