I have a problem with this code shows me the following "It has been defined by user-defined type" I am new to this programming in VB Excel
GRACIAS Function empleado(num As Integer) As String Dim Cnn As ADODB.Connection Dim Archivo As ADODB.Recordset Dim Sql, Sqlc, busca As String Set Cnn = New ADODB.Connection busca = (num) Set Archivo = New ADODB.Recordset Sqlc = "Driver={SQL Server};Server=SAPSERVER;Database=INTEGRADORA;Uid=sa;Pwd=B1Admin;" Cnn.Open Sqlc ' Sql = "SELECT user_code, u_name FROM ousr WHERE user_code= '" & busca & "'" Sql = "SELECT Slpcode,SlpName FROM OSLP Where Slpcode = " & busca & "" Archivo.Open Sql, Cnn If Not Archivo.EOF Then empleado = Archivo.slpname End If End Function --~--~---------~--~----~------------~-------~--~----~ ------------------------------------------------------------------------------------- Some important links for excel users: 1. Excel and VBA Tutorials(Video and Text), Free add-ins downloads at http://www.excelitems.com 2. Excel tutorials at http://www.excel-macros.blogspot.com 3. Learn VBA Macros at http://www.vbamacros.blogspot.com 4. Excel Tips and Tricks at http://exceldailytip.blogspot.com To post to this group, send email to excel-macros@googlegroups.com If you find any spam message in the group, please send an email to: Ayush Jain @ jainayus...@gmail.com or Ashish Jain @ 26may.1...@gmail.com ------------------------------------------------------------------------------------- -~----------~----~----~----~------~----~------~--~---