Dim sql As String
nome = VBA.Left(cmbuser.Text, InStr(1, cmbuser.Text, " ", vbBinaryCompare))
Set conn = New ADODB.Connection
sql = "select nome from user where nome='" '" & VBA.Left(cmbuser.Text, InStr(1, cmbuser.Text, " ", vbBinaryCompare)) & "'"
rs.Open sql, conn
If Not rs.EOF Then
cmbuser = rs!nome
You have to open the connection first, before it can be used. And, you need to Declare/Instanciate the recordset as well.
Dim Conn as ADODB.Connection
Dim rs as ADODB.Recordset
Set Conn = New ADODB.Connection
set rs = new ADODB.Recordset
rs.Open SQL, cn
"Lisa, in this house, we obey the laws of thermodynamics!" - Homer Simpson
"I have my standards. They may be low, but I have them!" - Bette Middler
"It's a book about a Spanish guy named Manual. You should read it." - Dilbert