I have the below function added to "this workbook" in order to fetch a number from a local SQL-Server database based on a value (typicaly from another cell).
Well, if I call the function in a form button, I get a return value, which is correct.
But, if I use the function in a cell, nothing happens...
Am I missing something obvious? I must admit I've never made use of functions this way, always through forms etc. so quite possible I'm missing something :-)
Cheers, Trin
Code:
Function FindGID(IPD As Variant)
Dim GIDdns As New ADODB.Connection
Dim ipdnParam As New ADODB.Parameter
Dim GIDrs As ADODB.Recordset
Dim kommando As New ADODB.Command
GIDdns =my dns info
GIDdns.Open
ipdnParam.Type = adInteger
ipdnParam = IPD
kommando.ActiveConnection = GIDdns
kommando.CommandText = "ket.EXCEL_IPDfind"
kommando.CommandType = adCmdStoredProc
kommando.Parameters.Append ipdnParam
Set GIDrs = kommando.Execute
FindGID = GIDrs!medlemsnummer
GIDdns.Close
End Function