codice:
Private Sub txtCognome_LostFocus()
If txtCognome.Text <> "" Then
txtNome.Enabled = True
End If
Dim dbConn As New ADODB.Connection
Dim dbRecCognome As New ADODB.Recordset
Dim strSQLCognome As String
Dim iCognome As String
iCognome = txtCognome
g_strConnectionString = "maia" ' uhm.. maia? :dottò:
dbConn.ConnectionString = g_strConnectionString
dbConn.Open
dbRecCognome.Open "Staff", dbConn, adOpenForwardOnly, adLockOptimistic, -1
strSQLCognome = "SELECT * FROM Staff WHERE Cognome = '" & iCognome & "'"
Set dbRecCognome = dbConn.Execute(strSQLCognome)
if dbRecCognome.RecordCount = 0 then
Msgbox"Cognome non trovato"
'chiudi il recordset e ciò che non ti serve
exit sub
else
Do While dbRecCognome.EOF = False
ListCognome.AddItem dbRecCognome!Cognome & vbTab & dbRecCognome!Nome & vbTab & dbRecCognome!Ruolo
dbRecCognome.MoveNext
Loop
dbRecCognome.Close
Set dbRecCognome = Nothing
dbConn.Close
Set dbConn = Nothing
end if
txtCognome.Text = UCase(txtCognome.Text)
txtCognome.Text = Replace(txtCognome.Text, " ", " ", 1, -1)
End Sub
oggi mi sento particolarmente buono.....